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.
6 7 8 9 10 11 |
# File 'lib/makeleaps/response/access_token.rb', line 6 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.
4 5 6 |
# File 'lib/makeleaps/response/access_token.rb', line 4 def body @body end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
4 5 6 |
# File 'lib/makeleaps/response/access_token.rb', line 4 def response @response end |
Instance Method Details
#access_token ⇒ Object
13 14 15 |
# File 'lib/makeleaps/response/access_token.rb', line 13 def access_token @access_token ||= body['access_token'] end |
#valid? ⇒ Boolean
17 18 19 |
# File 'lib/makeleaps/response/access_token.rb', line 17 def valid? response && response.status == 200 && !expired? end |