Class: HTTParty::Response

Inherits:
BasicObject
Defined in:
lib/httparty/response.rb

Overview

:nodoc:

Defined Under Namespace

Classes: Headers

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response, parsed_response) ⇒ Response

Returns a new instance of Response.



33
34
35
36
37
38
# File 'lib/httparty/response.rb', line 33

def initialize(response, parsed_response)
  @response = response
  @body = response.body
  @parsed_response = parsed_response
  @headers = Headers.new(response.to_hash)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



52
53
54
55
56
57
58
59
60
# File 'lib/httparty/response.rb', line 52

def method_missing(name, *args, &block)
  if parsed_response.respond_to?(name)
    parsed_response.send(name, *args, &block)
  elsif response.respond_to?(name)
    response.send(name, *args, &block)
  else
    super
  end
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



31
32
33
# File 'lib/httparty/response.rb', line 31

def body
  @body
end

#headersObject (readonly)

Returns the value of attribute headers.



31
32
33
# File 'lib/httparty/response.rb', line 31

def headers
  @headers
end

#parsed_responseObject (readonly)

Returns the value of attribute parsed_response.



31
32
33
# File 'lib/httparty/response.rb', line 31

def parsed_response
  @parsed_response
end

#responseObject (readonly)

Returns the value of attribute response.



31
32
33
# File 'lib/httparty/response.rb', line 31

def response
  @response
end

Instance Method Details

#classObject



40
41
42
# File 'lib/httparty/response.rb', line 40

def class
  Object.instance_method(:class).bind(self).call
end

#codeObject



44
45
46
# File 'lib/httparty/response.rb', line 44

def code
  response.code.to_i
end

#inspectObject



48
49
50
# File 'lib/httparty/response.rb', line 48

def inspect
  %(<#{self.class} @response=#{response.inspect}>)
end