MongoMapper provides ActiveModel-compatible serialization for building an XML or JSON representation of your model.
Call to_json or to_xml on your model to return a serialized string, or serializable_hash to simply return a plain Ruby hash.
Note that embedded documents are included in the serialized output without any intervention.
Customizing Serialized Output
The to_json and to_xml methods take a few options, namely :only, :except and :include. The first two are straightforward filters for the generation of the serialized output.
:include lets you include an association or the result of a method in the serialized output.
:methods lets you include the result of a method
Internally, the serializable_hash method is used on your model to generate the serialized string. Override it provide your own implementation or to set defaults.