Class: Rakuten::Response

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

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Response

Returns a new instance of Response.



5
6
7
8
# File 'lib/rakuten/api/response.rb', line 5

def initialize(response)
  @response =response
  @body = JSON.parse(@response.body)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/rakuten/api/response.rb', line 18

def method_missing(name, *args, &block)
  if @body.respond_to?(name)
    @body.send(name, *args, &block)
  else
    super
  end
end

Instance Method Details

#codeObject



10
11
12
# File 'lib/rakuten/api/response.rb', line 10

def code
  @response.code.to_i
end

#messageObject



14
15
16
# File 'lib/rakuten/api/response.rb', line 14

def message
  @response.message
end