Class: SimpleJsonApi::ArraySerializer

Inherits:
Serializer
  • Object
show all
Defined in:
lib/simple_json_api/array_serializer.rb

Overview

The ArraySerializer will serialize a collection

Instance Attribute Summary

Attributes inherited from Serializer

#_builder, #_each_serializer, #_object

Attributes included from DSL

#_associations, #_attributes

Instance Method Summary collapse

Methods inherited from Serializer

for, for_polymorphic, for_regular, #initialize, register_serializer

Methods included from DSL

#attribute, #belongs_to, #default_fields, #has_many, #has_one, #inherited, #serializes

Constructor Details

This class inherits a constructor from SimpleJsonApi::Serializer

Instance Method Details

#_root_nameObject



12
13
14
# File 'lib/simple_json_api/array_serializer.rb', line 12

def _root_name
  _each_serializer._root_name
end

#serializeObject



5
6
7
8
9
10
# File 'lib/simple_json_api/array_serializer.rb', line 5

def serialize
  _object.map do |object|
    serializer = _each_serializer.new(object: object, builder: _builder)
    serializer.serialize
  end
end