Class: Delphix::WebResponse
- Inherits:
-
Object
- Object
- Delphix::WebResponse
- Includes:
- Net::HTTPHeader
- Defined in:
- lib/delphix/web_response.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#cookies ⇒ Object
readonly
Returns the value of attribute cookies.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#method ⇒ #raw_body
readonly
The current session cookies.
-
#raw_body ⇒ Object
readonly
Returns the value of attribute raw_body.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(response) ⇒ WebResponse
constructor
A new instance of WebResponse.
- #inspect ⇒ Object
- #method_missing(name, *args, &block) ⇒ Object
- #respond_to?(method) ⇒ Boolean
Constructor Details
#initialize(response) ⇒ WebResponse
Returns a new instance of WebResponse.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/delphix/web_response.rb', line 48 def initialize(response) @code = response.code @headers = response.headers @raw_body = response @body = @raw_body @cookies = response. Delphix.last_response = { code: response.code, headers: response.headers, body: JSON.parse(response.body), cookies: response., description: response.description }.recursively_normalize_keys begin @body = JSON.parse(@raw_body) rescue Exception end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
77 78 79 80 81 82 83 |
# File 'lib/delphix/web_response.rb', line 77 def method_missing(name, *args, &block) if @headers.respond_to?(name) @headers.send(name, *args, &block) else super end end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
38 39 40 |
# File 'lib/delphix/web_response.rb', line 38 def body @body end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
29 30 31 |
# File 'lib/delphix/web_response.rb', line 29 def code @code end |
#cookies ⇒ Object (readonly)
Returns the value of attribute cookies.
46 47 48 |
# File 'lib/delphix/web_response.rb', line 46 def @cookies end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
42 43 44 |
# File 'lib/delphix/web_response.rb', line 42 def headers @headers end |
#method ⇒ #raw_body (readonly)
The current session cookies.
33 |
# File 'lib/delphix/web_response.rb', line 33 attr_reader :raw_body |
#raw_body ⇒ Object (readonly)
Returns the value of attribute raw_body.
33 34 35 |
# File 'lib/delphix/web_response.rb', line 33 def raw_body @raw_body end |
Instance Method Details
#==(other) ⇒ Object
69 70 71 |
# File 'lib/delphix/web_response.rb', line 69 def ==(other) @headers == other end |
#inspect ⇒ Object
73 74 75 |
# File 'lib/delphix/web_response.rb', line 73 def inspect @headers.inspect end |
#respond_to?(method) ⇒ Boolean
85 86 87 |
# File 'lib/delphix/web_response.rb', line 85 def respond_to?(method) super || @headers.respond_to?(method) end |