Class: AccessTokenAgent::Token
- Inherits:
-
Object
- Object
- AccessTokenAgent::Token
- Defined in:
- lib/access_token_agent/token.rb
Constant Summary collapse
- EXPIRY_MARGIN =
seconds
60
Instance Attribute Summary collapse
-
#expires_at ⇒ Object
readonly
Returns the value of attribute expires_at.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize(auth_response) ⇒ Token
constructor
A new instance of Token.
- #valid? ⇒ Boolean
Constructor Details
#initialize(auth_response) ⇒ Token
Returns a new instance of Token.
10 11 12 13 14 15 |
# File 'lib/access_token_agent/token.rb', line 10 def initialize(auth_response) validate_response(auth_response) @value = auth_response['access_token'] @expires_at = Time.now + auth_response['expires_in'] end |
Instance Attribute Details
#expires_at ⇒ Object (readonly)
Returns the value of attribute expires_at.
6 7 8 |
# File 'lib/access_token_agent/token.rb', line 6 def expires_at @expires_at end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
6 7 8 |
# File 'lib/access_token_agent/token.rb', line 6 def value @value end |
Instance Method Details
#valid? ⇒ Boolean
17 18 19 |
# File 'lib/access_token_agent/token.rb', line 17 def valid? @expires_at - EXPIRY_MARGIN > Time.now end |