Class: Net::HTTPResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/arest.rb

Overview

Extensions to standard HTTPResponse

Instance Method Summary collapse

Instance Method Details

#deserializeObject

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

Returns:

  • (Boolean)


20
21
22
# File 'lib/arest.rb', line 20

def ok?
  Net::HTTPSuccess === self || Net::HTTPRedirection === self
end