Module: DataMapper::Serializer::Collection::ToYaml

Included in:
Collection
Defined in:
lib/dm-serializer/to_yaml.rb

Instance Method Summary collapse

Instance Method Details

#encode_with(coder) ⇒ undefined

A callback to encode the collection in the YAML stream

Parameters:

  • coder (#add)

    handles adding the values to the output

Returns:

  • (undefined)


140
141
142
# File 'lib/dm-serializer/to_yaml.rb', line 140

def encode_with(coder)
  coder.seq = to_a
end

#to_yaml(*args) ⇒ String

Serialize the collection to YAML

Examples:

yaml = collection.to_yaml  # => a valid YAML string

Parameters:

  • options (Hash)

Returns:

  • (String)


128
129
130
# File 'lib/dm-serializer/to_yaml.rb', line 128

def to_yaml(*args)
  to_a.to_yaml(*args)
end