Class: SwapiDev::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/swapi_dev/client/response.rb

Class Method Summary collapse

Class Method Details

.handle(http_response) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/swapi_dev/client/response.rb', line 5

def self.handle(http_response)
  if [Net::HTTPSuccess, Net::HTTPOK].member? http_response.class
    JsonSerializer.call(http_response.body)
  else
    ErrorSerializer.call(http_response)
  end
end