Class: ResoTransport::Authentication::Access
- Inherits:
-
Object
- Object
- ResoTransport::Authentication::Access
- Defined in:
- lib/reso_transport/authentication/access.rb
Overview
Session class for TokenAuth. This stores the access token, the token type (usually ‘Bearer`), and the expiration date of the token.
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#expires ⇒ Object
Returns the value of attribute expires.
-
#token_type ⇒ Object
Returns the value of attribute token_type.
Instance Method Summary collapse
- #expired? ⇒ Boolean
-
#initialize(options = {}) ⇒ Access
constructor
A new instance of Access.
- #valid? ⇒ Boolean
Constructor Details
#initialize(options = {}) ⇒ Access
Returns a new instance of Access.
8 9 10 11 12 |
# File 'lib/reso_transport/authentication/access.rb', line 8 def initialize( = {}) @access_token = [:access_token] @expires = Time.now + [:expires_in] @token_type = [:token_type] end |
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
6 7 8 |
# File 'lib/reso_transport/authentication/access.rb', line 6 def access_token @access_token end |
#expires ⇒ Object
Returns the value of attribute expires.
6 7 8 |
# File 'lib/reso_transport/authentication/access.rb', line 6 def expires @expires end |
#token_type ⇒ Object
Returns the value of attribute token_type.
6 7 8 |
# File 'lib/reso_transport/authentication/access.rb', line 6 def token_type @token_type end |
Instance Method Details
#expired? ⇒ Boolean
14 15 16 |
# File 'lib/reso_transport/authentication/access.rb', line 14 def expired? Time.now > expires end |
#valid? ⇒ Boolean
18 19 20 |
# File 'lib/reso_transport/authentication/access.rb', line 18 def valid? !!access_token && !expired? end |