Class: Clientele::Response

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#responseObject (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

Returns:

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