config/initializers/mongo_monkey_patches.rb
# Builds a new +Document+ from the supplied attributes.
#
# @example Build the document.
#   Mongoid::Factory.build(Person, { "name" => "Durran" })
#
# @param [ Class ] klass The class to instantiate from if _type is not present.
# @param [ Hash ] attributes The document attributes.
# @param [ Hash ] options The mass assignment scoping options.
#
# @return [ Document ] The instantiated document.
Builds a new +Document+ from the supplied attributes.
Builds a new + Document + from the supplied attributes .
def build(klass, attributes = nil)
      type = (attributes || {})[TYPE]
      if type && klass._types.include?(type)
        "MongoModel::#{type}".constantize.new(attributes)
      else
        klass.new(attributes)
      end
    end
def build ( klass , attributes = nil ) type = ( attributes || { } ) [ TYPE ] if type && klass . _types . include? ( type ) "MongoModel::#{type}" . constantize . new ( attributes ) else klass . new ( attributes ) end end
Builds a new +Document+ from the supplied attributes.
Builds a new + Document + from the supplied attributes .
# klass = "MongoModel::#{klass}"
The instantiated document.
The instantiated document .
 Document 
klass
attributes
options The mass assignment scoping options.
options The mass assignment scoping options .
example
Build the document. Mongoid::Factory.build(Person, { "name" => "Durran" })
Build the document . Mongoid :: Factory . build ( Person { " name " = > " Durran " } )