Class: Cereals::ArraySerializer
- Inherits:
-
Object
- Object
- Cereals::ArraySerializer
- Defined in:
- lib/cereals/array_serializer.rb
Instance Method Summary collapse
-
#initialize(objects, root) ⇒ ArraySerializer
constructor
objects must respond to :serializer root is a string, the name of the root JSON key.
- #to_json ⇒ Object
Constructor Details
#initialize(objects, root) ⇒ ArraySerializer
objects must respond to :serializer root is a string, the name of the root JSON key
7 8 9 10 |
# File 'lib/cereals/array_serializer.rb', line 7 def initialize(objects, root) @objects = objects @root = root end |
Instance Method Details
#to_json ⇒ Object
12 13 14 |
# File 'lib/cereals/array_serializer.rb', line 12 def to_json { @root => wrap_objects.as_json(root: false) }.to_json end |