Class: Bambora::Response
- Inherits:
-
Object
- Object
- Bambora::Response
- Defined in:
- lib/bambora/adapters/response.rb
Overview
Parses a response into a Hash. Uses JSON to parse by default.
Direct Known Subclasses
Constant Summary collapse
- DEFAULT_PARSER =
JSON
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
-
#initialize(response) ⇒ Response
constructor
A new instance of Response.
- #to_h ⇒ Object
Constructor Details
#initialize(response) ⇒ Response
Returns a new instance of Response.
11 12 13 |
# File 'lib/bambora/adapters/response.rb', line 11 def initialize(response) @response = response end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
9 10 11 |
# File 'lib/bambora/adapters/response.rb', line 9 def response @response end |
Instance Method Details
#to_h ⇒ Object
15 16 17 18 19 |
# File 'lib/bambora/adapters/response.rb', line 15 def to_h deep_transform_keys_in_object(parser.parse(response.body.to_s), &:to_sym) rescue JSON::ParserError error_response end |