Class: RestClient::Response
- Inherits:
-
AbstractResponse
- Object
- AbstractResponse
- RestClient::Response
- Defined in:
- lib/restclient/response.rb
Overview
A Response from RestClient, you can access the response body, the code or the headers.
Constant Summary collapse
- WARNING_MESSAGE =
'[warning] The Response is no more a String and the Response content is now accessed through Response.body, please update your code'
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
Attributes inherited from AbstractResponse
Instance Method Summary collapse
- #==(o) ⇒ Object
-
#initialize(body, net_http_res, args) ⇒ Response
constructor
A new instance of Response.
- #method_missing(symbol, *args) ⇒ Object
- #size ⇒ Object
- #to_s ⇒ Object
Methods inherited from AbstractResponse
beautify_headers, #code, #cookies, #follow_redirection, #headers, #inspect, #raw_headers, #return!
Constructor Details
#initialize(body, net_http_res, args) ⇒ Response
Returns a new instance of Response.
11 12 13 14 |
# File 'lib/restclient/response.rb', line 11 def initialize body, net_http_res, args super net_http_res, args @body = body || "" end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(symbol, *args) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/restclient/response.rb', line 16 def method_missing symbol, *args if body.respond_to? symbol warn WARNING_MESSAGE body.send symbol, *args else super end end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
7 8 9 |
# File 'lib/restclient/response.rb', line 7 def body @body end |
Instance Method Details
#==(o) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/restclient/response.rb', line 25 def == o if super true else equal_body = (body == o) if equal_body warn WARNING_MESSAGE end equal_body end end |
#size ⇒ Object
41 42 43 |
# File 'lib/restclient/response.rb', line 41 def size body.size end |
#to_s ⇒ Object
37 38 39 |
# File 'lib/restclient/response.rb', line 37 def to_s body.to_s end |