Module: DataMapper::Serializer::ValidationErrors::ToYaml

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

Instance Method Summary collapse

Instance Method Details

#encode_with(coder) ⇒ undefined

A callback to encode the errors in the YAML stream

Parameters:

  • coder (#add)

    handles adding the values to the output

Returns:

  • (undefined)


108
109
110
# File 'lib/dm-serializer/to_yaml.rb', line 108

def encode_with(coder)
  coder.map = Hash[errors]
end

#to_yaml(*args) ⇒ String

Serialize the errors to YAML

Examples:

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

Parameters:

  • options (Hash)

Returns:

  • (String)


96
97
98
# File 'lib/dm-serializer/to_yaml.rb', line 96

def to_yaml(*args)
  Hash[errors].to_yaml(*args)
end