Class: HTTParty::Response

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

Overview

:nodoc:

Constant Summary collapse

RESPONDS_TO =
/^((body|code|message|headers)=?|delegate)$/

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(delegate, body, code, message, headers = {}) ⇒ Response

Returns a new instance of Response.



7
8
9
10
11
12
13
# File 'lib/httparty/response.rb', line 7

def initialize(delegate, body, code, message, headers={})
  @delegate = delegate
  @body = body
  @code = code.to_i
  @message = message
  @headers = headers
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



15
16
17
# File 'lib/httparty/response.rb', line 15

def method_missing(name, *args, &block)
  @delegate.send(name, *args, &block)
end

Instance Attribute Details

#bodyObject

Returns the value of attribute body.



4
5
6
# File 'lib/httparty/response.rb', line 4

def body
  @body
end

#codeObject

Returns the value of attribute code.



4
5
6
# File 'lib/httparty/response.rb', line 4

def code
  @code
end

#delegateObject (readonly)

Returns the value of attribute delegate.



5
6
7
# File 'lib/httparty/response.rb', line 5

def delegate
  @delegate
end

#headersObject

Returns the value of attribute headers.



4
5
6
# File 'lib/httparty/response.rb', line 4

def headers
  @headers
end

#messageObject

Returns the value of attribute message.



4
5
6
# File 'lib/httparty/response.rb', line 4

def message
  @message
end

Instance Method Details

#respond_to?(method) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/httparty/response.rb', line 19

def respond_to?(method)
  return true if method.to_s.match(RESPONDS_TO)
end