Module | Mongoid::Factory |
In: |
lib/mongoid/factory.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 ] optiosn The mass assignment scoping options.
@return [ Document ] The instantiated document.
Builds a new Document from the supplied attributes loaded from the database.
@example Build the document.
Mongoid::Factory.from_db(Person, { "name" => "Durran" })
@param [ Class ] klass The class to instantiate from if _type is not present. @param [ Hash ] attributes The document attributes.
@return [ Document ] The instantiated document.