Sha256: c071559ba325bdf0ce42798732db08d35b6122043e7eea841459438d2c0add2a

Contents?: true

Size: 426 Bytes

Versions: 4

Compression:

Stored size: 426 Bytes

Contents

class Token < ActiveRecord::Base
  belongs_to :tokenizable, polymorphic: true
  serialize :data, Tokens::ActiveRecord::Serializer

  attr_readonly :tokenizable_id, :tokenizable_type

  def self.clean
    where("expires_at < ? AND expires_at IS NOT NULL", Time.now).delete_all
  end

  def data
    read_attribute(:data) || {}
  end

  def to_s
    token
  end

  def expired?
    expires_at && expires_at < Time.now
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tokens-2.1.1 lib/tokens/token.rb
tokens-2.1.0 lib/tokens/token.rb
tokens-2.0.1 lib/tokens/token.rb
tokens-2.0.0 lib/tokens/token.rb