Class: Net::HTTPResponse
- Inherits:
-
Object
- Object
- Net::HTTPResponse
- Defined in:
- lib/arest.rb
Overview
Extensions to standard HTTPResponse
Instance Method Summary collapse
-
#deserialize ⇒ Object
Find out the content type of the response and convert it the proper object.
-
#ok? ⇒ Boolean
True if response is HTTP OK.
Instance Method Details
#deserialize ⇒ Object
Find out the content type of the response and convert it the proper object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/arest.rb', line 8 def deserialize case content_type when "application/xml" Hash.from_xml(body).deep_symbolize_keys when "application/json" JSON.parse body, symbolize_names: true else body end end |
#ok? ⇒ Boolean
True if response is HTTP OK
20 21 22 |
# File 'lib/arest.rb', line 20 def ok? Net::HTTPSuccess === self || Net::HTTPRedirection === self end |