Module: Cloverly::Base::ClassMethods

Defined in:
lib/cloverly/base.rb

Instance Method Summary collapse

Instance Method Details

#parse(cloverly_instance, json_response) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/cloverly/base.rb', line 28

def parse(cloverly_instance, json_response)
  if json_response.is_a?(Array)
    json_response.map do |item_json|
      self.parse(cloverly_instance, item_json)
    end
  else
    instance = self.new(cloverly_instance)

    instance.json = json_response
    instance.attributes = json_response

    instance
  end
end