class Oshpark::Token

Attributes

expires_at[RW]

Public Class Methods

attrs() click to toggle source
# File lib/oshpark/token.rb, line 11
def self.attrs
  %w| token ttl user_id |
end
new(json={}) click to toggle source
Calls superclass method Oshpark::Model::new
# File lib/oshpark/token.rb, line 6
def initialize json={}
  super
  @expires_at = Time.now + (@ttl || 0)
end

Public Instance Methods

authentic?() click to toggle source
# File lib/oshpark/token.rb, line 29
def authentic?
  valid? && !!user_id
end
ttl() click to toggle source
# File lib/oshpark/token.rb, line 17
def ttl
  expires_at - Time.now
end
user() click to toggle source
# File lib/oshpark/token.rb, line 21
def user
  User.from_json 'id' => user_id
end
valid?() click to toggle source
# File lib/oshpark/token.rb, line 25
def valid?
  ttl > 0
end