Class: Makeleaps::Response::TokenStore
- Inherits:
-
Object
- Object
- Makeleaps::Response::TokenStore
- Defined in:
- lib/makeleaps/response/access_token.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
- #access_token ⇒ Object
-
#initialize(response) ⇒ TokenStore
constructor
A new instance of TokenStore.
- #valid? ⇒ Boolean
Constructor Details
#initialize(response) ⇒ TokenStore
Returns a new instance of TokenStore.
8 9 10 11 12 13 |
# File 'lib/makeleaps/response/access_token.rb', line 8 def initialize(response) @response = response @body = JSON.parse(response.body) rescue JSON::JSONError @body = nil end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
6 7 8 |
# File 'lib/makeleaps/response/access_token.rb', line 6 def body @body end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
6 7 8 |
# File 'lib/makeleaps/response/access_token.rb', line 6 def response @response end |
Instance Method Details
#access_token ⇒ Object
15 16 17 |
# File 'lib/makeleaps/response/access_token.rb', line 15 def access_token @access_token ||= body['access_token'] end |
#valid? ⇒ Boolean
19 20 21 |
# File 'lib/makeleaps/response/access_token.rb', line 19 def valid? response && response.status == 200 && !expired? end |