Class: Dm3::Api::Responses::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/dm3/api/responses/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_response) ⇒ Base

Returns a new instance of Base.



4
5
6
7
8
9
# File 'lib/dm3/api/responses/base.rb', line 4

def initialize(raw_response)
  @raw_response = raw_response
  @json = raw_response.body
  @hash = JSON.parse(json)
  @dish = Dish(hash)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args, &block) ⇒ Object



11
12
13
# File 'lib/dm3/api/responses/base.rb', line 11

def method_missing(*args, &block)
  dish.public_send(args.first)
end

Instance Attribute Details

#dishObject (readonly)

Returns the value of attribute dish.



2
3
4
# File 'lib/dm3/api/responses/base.rb', line 2

def dish
  @dish
end

#hashObject (readonly)

Returns the value of attribute hash.



2
3
4
# File 'lib/dm3/api/responses/base.rb', line 2

def hash
  @hash
end

#jsonObject (readonly)

Returns the value of attribute json.



2
3
4
# File 'lib/dm3/api/responses/base.rb', line 2

def json
  @json
end

#raw_responseObject (readonly)

Returns the value of attribute raw_response.



2
3
4
# File 'lib/dm3/api/responses/base.rb', line 2

def raw_response
  @raw_response
end