<commit_before>module Landable
  class AccessToken < ActiveRecord::Base
    include Landable::TableName

    # Maximum token age, in hours
    MAX_AGE = (Landable.configuration['ldap'][:access_token_max_age] || 8).hours

    belongs_to :author
    validates_presence_of :author_id
    validates_presence_of :expires_at
    validates_presence_of :permissions

    before_validation do |token|
      token.expires_at ||= expiration
    end

    scope :fresh,   -> { where('expires_at > ?',  Time.zone.now) }
    scope :expired, -> { where('expires_at <= ?', Time.zone.now) }

    def refresh!
      update_column :expires_at, expiration
    end

    def can_publish?
      permissions['publish'] == 'true'
    end

    def can_edit?
      permissions['edit'] == 'true'
    end

    def can_read?
      permissions['read'] == 'true'
    end

    private<commit_msg>cleaned up nilcheck. it should work now!<commit_after>module Landable
  class AccessToken < ActiveRecord::Base
    include Landable::TableName

    # Maximum token age, in hours
    MAX_AGE = ( (Landable.configuration['ldap'] &&
                 Landable.configuration['ldap'][:access_token_max_age]) || 8 ).hours

    belongs_to :author
    validates_presence_of :author_id
    validates_presence_of :expires_at
    validates_presence_of :permissions

    before_validation do |token|
      token.expires_at ||= expiration
    end

    scope :fresh,   -> { where('expires_at > ?',  Time.zone.now) }
    scope :expired, -> { where('expires_at <= ?', Time.zone.now) }

    def refresh!
      update_column :expires_at, expiration
    end

    def can_publish?
      permissions['publish'] == 'true'
    end

    def can_edit?
      permissions['edit'] == 'true'
    end

    def can_read?
      permissions['read'] == 'true'
    end

    private
{'fraction_non_alphanumeric': 0.11129568106312292, 'fraction_numerical': 0.0011074197120708748, 'mean_word_length': 3.033482142857143, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5431438', 'n_tokens_mistral': 591, 'n_tokens_neox': 568, 'n_words': 125}