Class: Goauth2::HashResponse
- Inherits:
-
Object
- Object
- Goauth2::HashResponse
- Defined in:
- lib/goauth2/hash_response.rb
Instance Attribute Summary collapse
-
#hash ⇒ Object
Returns the value of attribute hash.
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
- #first ⇒ Object
-
#initialize(response) ⇒ HashResponse
constructor
A new instance of HashResponse.
- #method_missing(name) ⇒ Object
Constructor Details
#initialize(response) ⇒ HashResponse
Returns a new instance of HashResponse.
5 6 7 8 9 |
# File 'lib/goauth2/hash_response.rb', line 5 def initialize(response) @response = response @hash = JSON.parse(response.body) @hash = @hash['data'] if @hash['data'] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/goauth2/hash_response.rb', line 15 def method_missing(name) val = @hash[name] if @hash.key? name @hash.each { |k,v| val = v if k.to_s.to_sym == name } unless val if val return wrap(val) end super.method_missing name end |
Instance Attribute Details
#hash ⇒ Object
Returns the value of attribute hash.
3 4 5 |
# File 'lib/goauth2/hash_response.rb', line 3 def hash @hash end |
#response ⇒ Object
Returns the value of attribute response.
3 4 5 |
# File 'lib/goauth2/hash_response.rb', line 3 def response @response end |
Instance Method Details
#first ⇒ Object
11 12 13 |
# File 'lib/goauth2/hash_response.rb', line 11 def first wrap(@hash.first) end |