Module: Ivy::Serializers::Documents

Defined in:
lib/ivy/serializers/documents.rb,
lib/ivy/serializers/documents/document.rb,
lib/ivy/serializers/documents/individual_resource.rb,
lib/ivy/serializers/documents/resource_collection.rb

Defined Under Namespace

Classes: Document, IndividualResource, ResourceCollection

Class Method Summary collapse

Class Method Details

.create(serializer, primary_resource_name, primary_resource) ⇒ Object



7
8
9
10
# File 'lib/ivy/serializers/documents.rb', line 7

def self.create(serializer, primary_resource_name, primary_resource)
  klass = document_class_for(primary_resource)
  klass.new(serializer, primary_resource_name, primary_resource)
end

.document_class_for(resource) ⇒ Object



12
13
14
# File 'lib/ivy/serializers/documents.rb', line 12

def self.document_class_for(resource)
  resource.respond_to?(:to_ary) ? ResourceCollection : IndividualResource
end