Module: Knuckles::Stages::Dumper

Extended by:
Dumper
Included in:
Dumper
Defined in:
lib/knuckles/stages/dumper.rb

Overview

The dumping process combines de-duplication and actual serialization. For every top level key that is an array all of the children will have uniqueness enforced. For example, if you had rendered a collection of posts that shared the same author, you will only have a single author object serialized. Be aware that the uniqueness check relies on the presence of an ‘id` key rather than full object comparisons.

Instance Method Summary collapse

Instance Method Details

#call(objects, _options) ⇒ Object

De-duplicate values in all keys and merge them into a single hash. Afterwards the complete hash is serialized using the serializer configured at ‘Knuckles.serializer`.

Parameters:

  • objects (Enumerable<Hash>)

    A collection of hashes to be dumped

  • _options (Hash)

    Options aren’t used, but are accepted to maintain a consistent interface



22
23
24
# File 'lib/knuckles/stages/dumper.rb', line 22

def call(objects, _options)
  Knuckles.serializer.dump(keys_to_arrays(objects))
end