Class: XSR::Response
- Inherits:
-
Object
- Object
- XSR::Response
- Defined in:
- lib/xsr/response.rb
Overview
Response object is created by Client after a HTTP call
Instance Attribute Summary collapse
-
#http_response ⇒ Object
readonly
Returns the value of attribute http_response.
Instance Method Summary collapse
- #bad_request? ⇒ Boolean
- #body ⇒ Object
- #forbidden? ⇒ Boolean
-
#initialize(http_response) ⇒ Response
constructor
A new instance of Response.
- #not_found? ⇒ Boolean
- #server_error? ⇒ Boolean
- #success? ⇒ Boolean
- #unauthorized? ⇒ Boolean
Constructor Details
#initialize(http_response) ⇒ Response
6 7 8 |
# File 'lib/xsr/response.rb', line 6 def initialize(http_response) @http_response = http_response end |
Instance Attribute Details
#http_response ⇒ Object (readonly)
Returns the value of attribute http_response.
4 5 6 |
# File 'lib/xsr/response.rb', line 4 def http_response @http_response end |
Instance Method Details
#bad_request? ⇒ Boolean
14 15 16 |
# File 'lib/xsr/response.rb', line 14 def bad_request? @http_response.is_a? Net::HTTPBadRequest end |
#body ⇒ Object
34 35 36 |
# File 'lib/xsr/response.rb', line 34 def body MultiJson.load @http_response.body, symbolize_keys: true end |
#forbidden? ⇒ Boolean
26 27 28 |
# File 'lib/xsr/response.rb', line 26 def forbidden? @http_response.is_a? Net::HTTPForbidden end |
#not_found? ⇒ Boolean
18 19 20 |
# File 'lib/xsr/response.rb', line 18 def not_found? @http_response.is_a? Net::HTTPNotFound end |
#server_error? ⇒ Boolean
30 31 32 |
# File 'lib/xsr/response.rb', line 30 def server_error? @http_response.is_a? Net::HTTPServerError end |
#success? ⇒ Boolean
10 11 12 |
# File 'lib/xsr/response.rb', line 10 def success? @http_response.is_a? Net::HTTPSuccess end |
#unauthorized? ⇒ Boolean
22 23 24 |
# File 'lib/xsr/response.rb', line 22 def @http_response.is_a? Net:: end |