Module: Restool::Traversal::Converter

Defined in:
lib/restool/traversal/converter.rb

Class Method Summary collapse

Class Method Details

.convert(request_response, response_representation, representations) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/restool/traversal/converter.rb', line 19

def self.convert(request_response, response_representation, representations)
  object = Restool::Traversal::Object.new

  object.class.__send__(:attr_accessor, :_raw)
  object.__send__("_raw=", request_response)

  if request_response.is_a?(Array)
    request_response.map do |element|
      map_response_to_representation(response_representation, element, object, representations)
    end
  else
    map_response_to_representation(response_representation, request_response, object, representations)
  end
end