Sha256: fa2664e6e8a65980350473fac78dfaee4a49e0b1aa8ab278a731a933aece7224

Contents?: true

Size: 499 Bytes

Versions: 16

Compression:

Stored size: 499 Bytes

Contents

module Landable
  class AccessToken < ActiveRecord::Base
    include Landable::TableName
    
    belongs_to :author
    validates_presence_of :author_id
    validates_presence_of :expires_at

    before_validation do |token|
      token.expires_at ||= 8.hours.from_now
    end

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

    def refresh!
      update_column :expires_at, 8.hours.from_now
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
landable-1.13.1 app/models/landable/access_token.rb
landable-1.12.3 app/models/landable/access_token.rb
landable-1.12.2 app/models/landable/access_token.rb
landable-1.12.1 app/models/landable/access_token.rb
landable-1.11.1 app/models/landable/access_token.rb
landable-1.11.0 app/models/landable/access_token.rb
landable-1.10.0.rc2 app/models/landable/access_token.rb
landable-1.10.0.rc1 app/models/landable/access_token.rb
landable-1.9.2 app/models/landable/access_token.rb
landable-1.9.1 app/models/landable/access_token.rb
landable-1.9.0 app/models/landable/access_token.rb
landable-1.9.0.rc2 app/models/landable/access_token.rb
landable-1.9.0.rc1 app/models/landable/access_token.rb
landable-1.8.0 app/models/landable/access_token.rb
landable-1.7.1.rc1 app/models/landable/access_token.rb
landable-1.7.0 app/models/landable/access_token.rb