Class: ApiRecipes::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/api_recipes/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_responseObject (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

#dataObject



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