Module: Tessa::ResponseFactory

Included in:
Asset, Upload
Defined in:
lib/tessa/response_factory.rb

Instance Method Summary collapse

Instance Method Details

#new_from_response(response) ⇒ Object

Raises:



4
5
6
7
8
9
10
11
12
# File 'lib/tessa/response_factory.rb', line 4

def new_from_response(response)
  raise RequestFailed.new("Tessa responded with #{response.status}", response) unless response.success?
  case json = JSON.parse(response.body)
  when Array
    json.map { |record| new record }
  when Hash
    new json
  end
end