Class: Clientele::Response
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Clientele::Response
- Defined in:
- lib/clientele/response.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
-
#initialize(response, client: nil, resource: nil) ⇒ Response
constructor
A new instance of Response.
- #method_missing(method_name, *args, &block) ⇒ Object
- #respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Constructor Details
#initialize(response, client: nil, resource: nil) ⇒ Response
Returns a new instance of Response.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/clientele/response.rb', line 10 def initialize(response, client: nil, resource: nil) @response = response super( if resource resource.build response.body, client: client, klass: response.body.class else response.body end ) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/clientele/response.rb', line 25 def method_missing(method_name, *args, &block) begin super rescue NoMethodError @response.send method_name, *args, &block end end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
9 10 11 |
# File 'lib/clientele/response.rb', line 9 def response @response end |
Instance Method Details
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
21 22 23 |
# File 'lib/clientele/response.rb', line 21 def respond_to_missing?(method_name, include_private=false) @response.respond_to?(method_name, include_private) or super end |