Class: ApiRecipes::Response
- Inherits:
-
Object
- Object
- ApiRecipes::Response
- Defined in:
- lib/api_recipes/response.rb
Instance Attribute Summary collapse
-
#original_response ⇒ Object
readonly
Returns the value of attribute original_response.
Instance Method Summary collapse
- #data ⇒ Object
-
#initialize(response, attributes = {}) ⇒ Response
constructor
A new instance of Response.
-
#method_missing(symbol, *args, &block) ⇒ Object
Forward method calls to ‘original’ Response class.
Constructor Details
#initialize(response, attributes = {}) ⇒ Response
Returns a new instance of Response.
6 7 8 9 |
# File 'lib/api_recipes/response.rb', line 6 def initialize(response, attributes = {}) @original_response = response @attributes = attributes end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(symbol, *args, &block) ⇒ Object
Forward method calls to ‘original’ Response class
19 20 21 |
# File 'lib/api_recipes/response.rb', line 19 def method_missing(symbol, *args, &block) @original_response.send symbol,* args, &block end |
Instance Attribute Details
#original_response ⇒ Object (readonly)
Returns the value of attribute original_response.
4 5 6 |
# File 'lib/api_recipes/response.rb', line 4 def original_response @original_response end |
Instance Method Details
#data ⇒ Object
11 12 13 14 15 16 |
# File 'lib/api_recipes/response.rb', line 11 def data return @data unless @data.nil? # TODO: rescue nil? @data = @original_response.parse @attributes[:mime_type] end |