Class: Savon::Response
Overview
Savon::Response
Represents the HTTP and SOAP response.
Constant Summary collapse
- @@raise_errors =
The global setting of whether to raise errors.
true
Instance Attribute Summary collapse
-
#http ⇒ Object
readonly
Returns the HTTP response object.
-
#http_error ⇒ Object
readonly
Returns the HTTP error message.
-
#soap_error_code ⇒ Object
readonly
Returns the SOAP error code.
-
#soap_fault ⇒ Object
readonly
Returns the SOAP fault message.
Class Method Summary collapse
-
.error_handler(&blk) ⇒ Object
Sets a specific handler for errors to raise.
-
.raise_errors=(raise_errors) ⇒ Object
Sets the global setting of whether to raise errors.
-
.raise_errors? ⇒ Boolean
Returns the global setting of whether to raise errors.
Instance Method Summary collapse
-
#http_error? ⇒ Boolean
Returns whether there was an HTTP error.
-
#initialize(http) ⇒ Response
constructor
Expects a Net::HTTPResponse and handles errors.
-
#soap_fault? ⇒ Boolean
Returns whether there was a SOAP fault.
-
#to_hash ⇒ Object
Returns the SOAP response body as a Hash.
-
#to_xml ⇒ Object
(also: #to_s)
Returns the SOAP response XML.
Constructor Details
#initialize(http) ⇒ Response
Expects a Net::HTTPResponse and handles errors.
27 28 29 30 31 32 |
# File 'lib/savon/response.rb', line 27 def initialize(http) @http = http handle_soap_fault handle_http_error end |
Instance Attribute Details
#http ⇒ Object (readonly)
Returns the HTTP response object.
64 65 66 |
# File 'lib/savon/response.rb', line 64 def http @http end |
#http_error ⇒ Object (readonly)
Returns the HTTP error message.
51 52 53 |
# File 'lib/savon/response.rb', line 51 def http_error @http_error end |
#soap_error_code ⇒ Object (readonly)
Returns the SOAP error code
43 44 45 |
# File 'lib/savon/response.rb', line 43 def soap_error_code @soap_error_code end |
#soap_fault ⇒ Object (readonly)
Returns the SOAP fault message.
40 41 42 |
# File 'lib/savon/response.rb', line 40 def soap_fault @soap_fault end |
Class Method Details
.error_handler(&blk) ⇒ Object
Sets a specific handler for errors to raise.
22 23 24 |
# File 'lib/savon/response.rb', line 22 def self.error_handler(&blk) @@error_handler = blk end |
.raise_errors=(raise_errors) ⇒ Object
Sets the global setting of whether to raise errors.
12 13 14 |
# File 'lib/savon/response.rb', line 12 def self.raise_errors=(raise_errors) @@raise_errors = raise_errors end |
.raise_errors? ⇒ Boolean
Returns the global setting of whether to raise errors.
17 18 19 |
# File 'lib/savon/response.rb', line 17 def self.raise_errors? @@raise_errors end |
Instance Method Details
#http_error? ⇒ Boolean
Returns whether there was an HTTP error.
46 47 48 |
# File 'lib/savon/response.rb', line 46 def http_error? @http_error ? true : false end |
#soap_fault? ⇒ Boolean
Returns whether there was a SOAP fault.
35 36 37 |
# File 'lib/savon/response.rb', line 35 def soap_fault? @soap_fault ? true : false end |
#to_hash ⇒ Object
Returns the SOAP response body as a Hash.
54 55 56 |
# File 'lib/savon/response.rb', line 54 def to_hash @body ||= (Crack::XML.parse(@http.body) rescue {}).find_soap_body end |
#to_xml ⇒ Object Also known as: to_s
Returns the SOAP response XML.
59 60 61 |
# File 'lib/savon/response.rb', line 59 def to_xml @http.body end |