Class: Unit::Resource::BaseResource

Inherits:
Object
  • Object
show all
Defined in:
lib/unit/api_resources/base_resource.rb

Class Method Summary collapse

Class Method Details

.file_response_handler(response) ⇒ Object



14
15
16
# File 'lib/unit/api_resources/base_resource.rb', line 14

def file_response_handler(response)
  response.code.to_i.between?(200, 299) ? response.body : Unit::UnitError
end

.response_handler(response) ⇒ Object

Check the response code and return a UnitResponse or UnitError

Parameters:

  • response (HTTP::Response)


9
10
11
12
# File 'lib/unit/api_resources/base_resource.rb', line 9

def response_handler(response)
  handler = response.code.to_i.between?(200, 299) ? Unit::UnitResponse : Unit::UnitError
  handler.from_json_api(response)
end