Class: IesAuth::TokenManager
- Inherits:
-
Object
- Object
- IesAuth::TokenManager
- Includes:
- RequestDefaults
- Defined in:
- lib/ies_auth/token_manager.rb
Overview
TLD
Instance Attribute Summary collapse
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
- #data ⇒ Object
- #expiration ⇒ Object
- #expired? ⇒ Boolean
-
#initialize(token = nil) ⇒ TokenManager
constructor
A new instance of TokenManager.
- #user_id ⇒ Object
Methods included from RequestDefaults
#delete, #get, #ies_api_url, #post, #put
Constructor Details
#initialize(token = nil) ⇒ TokenManager
Returns a new instance of TokenManager.
10 11 12 13 14 |
# File 'lib/ies_auth/token_manager.rb', line 10 def initialize(token = nil) @token = token || create_token raise InvalidTokenStructureError unless token_duck?(@token) raise ExpiredTokenError if expired? end |
Instance Attribute Details
#token ⇒ Object (readonly)
Returns the value of attribute token.
8 9 10 |
# File 'lib/ies_auth/token_manager.rb', line 8 def token @token end |
Instance Method Details
#data ⇒ Object
16 17 18 |
# File 'lib/ies_auth/token_manager.rb', line 16 def data token.data end |
#expiration ⇒ Object
20 21 22 |
# File 'lib/ies_auth/token_manager.rb', line 20 def expiration token.expiration end |
#expired? ⇒ Boolean
24 25 26 |
# File 'lib/ies_auth/token_manager.rb', line 24 def expired? (Time.now <=> expiration).positive? end |
#user_id ⇒ Object
28 29 30 |
# File 'lib/ies_auth/token_manager.rb', line 28 def user_id token.user_id end |