Class: Strava::Web::Response
- Inherits:
-
Object
- Object
- Strava::Web::Response
- Includes:
- DeepCopyable
- Defined in:
- lib/strava/web/response.rb
Overview
wrapper class as abstraction for API response returned from the Faraday Adapter working with a deep copy, in order to not mutate the original request itself
Instance Attribute Summary collapse
-
#http_response ⇒ Object
readonly
Returns the value of attribute http_response.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
-
#initialize(http_response) ⇒ Response
constructor
A new instance of Response.
Methods included from DeepCopyable
Constructor Details
#initialize(http_response) ⇒ Response
Returns a new instance of Response.
17 18 19 20 |
# File 'lib/strava/web/response.rb', line 17 def initialize(http_response) @http_response = deep_copy(http_response) @response = conditional_response_upgrade!(http_response) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_symbol, *args, &block) ⇒ Object (private)
78 79 80 81 82 83 84 85 |
# File 'lib/strava/web/response.rb', line 78 def method_missing(method_symbol, *args, &block) case @response when Array @response.send(method_symbol, *args, &block) else operate_on_response_body!(method_symbol, *args, &block) end end |
Instance Attribute Details
#http_response ⇒ Object (readonly)
Returns the value of attribute http_response.
12 13 14 |
# File 'lib/strava/web/response.rb', line 12 def http_response @http_response end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
12 13 14 |
# File 'lib/strava/web/response.rb', line 12 def response @response end |