Module Mongoid::Serialization
In: lib/mongoid/serialization.rb

This module provides the extra behaviour for including relations in JSON and XML serialization.

Methods

Public Class methods

Serialize the provided object into a Mongo friendly value, using the field serialization method for the passed in type. If no type is given then we assume generic object serialization, which just returns the value itself.

@example Mongoize the object.

  Mongoid::Serialization.mongoize(time, Time)

@param [ Object ] object The object to convert. @param [ Class ] klass The type of the object.

@return [ Object ] The converted object.

@since 2.1.0

Public Instance methods

Gets the document as a serializable hash, used by ActiveModel‘s JSON serializer.

@example Get the serializable hash.

  document.serializable_hash

@example Get the serializable hash with options.

  document.serializable_hash(:include => :addresses)

@param [ Hash ] options The options to pass.

@option options [ Symbol ] :include What relations to include. @option options [ Symbol ] :only Limit the fields to only these. @option options [ Symbol ] :except Dont include these fields. @option options [ Symbol ] :methods What methods to include.

@return [ Hash ] The document, ready to be serialized.

@since 2.0.0.rc.6

[Validate]