Module: DrySerialization::JsonapiSerializer

Defined in:
lib/dry_serialization/jsonapi_serializer.rb,
lib/generators/dry_serialization/jsonapi_serializer/install_generator.rb

Defined Under Namespace

Classes: InstallGenerator

Instance Method Summary collapse

Instance Method Details

#serialized_resource(resource, serializer, options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/dry_serialization/jsonapi_serializer.rb', line 3

def serialized_resource(resource, serializer, options = {})
  if resource.is_a?(ActiveRecord::Relation) || resource.is_a?(Array)
    options[:is_collection] = true
  else
    options[:is_collection] = false
  end
  
  serializer.new(resource, options)
end