Module DataMapper::Serializer
In: lib/dm-serializer/xml/libxml.rb
lib/dm-serializer/xml/nokogiri.rb
lib/dm-serializer/xml/rexml.rb
lib/dm-serializer/to_json.rb
lib/dm-serializer/xml.rb
lib/dm-serializer/to_xml.rb
lib/dm-serializer/to_yaml.rb
lib/dm-serializer/to_csv.rb
lib/dm-serializer/common.rb

Methods

Classes and Modules

Module DataMapper::Serializer::Collection
Module DataMapper::Serializer::ValidationErrors
Module DataMapper::Serializer::XML

Constants

TAG_NAME = "ruby/DataMapper,#{DataMapper::VERSION}".freeze

Public Class methods

Include a callback to register the YAML output

@param [DataMapper::Model] descendant

@return [undefined]

@api private

Public Instance methods

Converts the resource into a hash of properties.

@param [Hash] options

  Additional options.

@return [Hash{String => String}]

  The hash of resources properties.

@since 1.0.1

A callback to encode the resource in the YAML stream

@param [add] coder

  handles adding the values to the output

@param [Hash] options

  optional Hash configuring the output

@return [undefined]

@api public

Returns propreties to serialize based on :only or :exclude arrays, if provided :only takes precendence over :exclude

@return [Array]

  Properties that need to be serialized.

Serialize a Resource to comma-separated values (CSV).

@return <String> a CSV representation of the Resource

Serialize a Resource to JavaScript Object Notation (JSON; RFC 4627)

@return <String> a JSON representation of the Resource

Serialize a Resource to XML.

@return [LibXML::Document, Nokogiri::Document, REXML::Document]

  An XML representation of this Resource.

This method requires certain methods to be implemented in the individual serializer library subclasses:

  • new_document
  • root_node
  • add_property_node
  • add_node

Serialize a Resource to YAML

@example

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

@param [Hash] options

@return [String]

@api public

[Validate]