Sha256: 3bb45435f0d784f0a3d7bd96f83d0fcbaa97724d7d92e1d737a838844158edb4

Contents?: true

Size: 528 Bytes

Versions: 4

Compression:

Stored size: 528 Bytes

Contents

require 'ivy/serializers/documents/individual_resource'
require 'ivy/serializers/documents/resource_collection'

module Ivy
  module Serializers
    module Documents
      def self.create(serializer, primary_resource_name, primary_resource)
        klass = document_class_for(primary_resource)
        klass.new(serializer, primary_resource_name, primary_resource)
      end

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ivy-serializers-0.4.0 lib/ivy/serializers/documents.rb
ivy-serializers-0.3.0 lib/ivy/serializers/documents.rb
ivy-serializers-0.2.0 lib/ivy/serializers/documents.rb
ivy-serializers-0.1.0 lib/ivy/serializers/documents.rb