module WCC::Data::Mapper::JSONResponse

Public Instance Methods

new_from_response(response) click to toggle source
# File lib/wcc/data/mapper/json_response.rb, line 5
def new_from_response(response)
  raise RecordNotFound if response.status == 404
  raise ServiceUnavailable if response.status == 503
  case response.json
  when Array
    response.json.collect { |obj| new(obj) }
  when Hash
    new(response.json)
  else
    raise InvalidResponse, "Cannot build object from response!"
  end
end