Class: Toke::AccessToken

Inherits:
Object
  • Object
show all
Defined in:
lib/toke/models/access_token.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash = {}) ⇒ AccessToken

Returns a new instance of AccessToken.



5
6
7
8
9
# File 'lib/toke/models/access_token.rb', line 5

def initialize(hash = {})
  @token      = hash['access_token']
  @expires    = hash['expires_in']
  @created_at = Time.now
end

Instance Attribute Details

#expiresObject

Returns the value of attribute expires.



3
4
5
# File 'lib/toke/models/access_token.rb', line 3

def expires
  @expires
end

#tokenObject

Returns the value of attribute token.



3
4
5
# File 'lib/toke/models/access_token.rb', line 3

def token
  @token
end

Instance Method Details

#expired?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/toke/models/access_token.rb', line 11

def expired?
   Time.now > @created_at + expires - (expires / 12)
end