Class: Mongoid::Relations::Builders::Embedded::One
- Inherits:
-
Mongoid::Relations::Builder
- Object
- Mongoid::Relations::Builder
- Mongoid::Relations::Builders::Embedded::One
- Defined in:
- lib/mongoid/relations/builders/embedded/one.rb
Overview
Instance Attribute Summary
Attributes inherited from Mongoid::Relations::Builder
Instance Method Summary collapse
-
#build(type = nil) ⇒ Document
Builds the document out of the attributes using the provided metadata on the relation.
Methods inherited from Mongoid::Relations::Builder
Constructor Details
This class inherits a constructor from Mongoid::Relations::Builder
Instance Method Details
#build(type = nil) ⇒ Document
Builds the document out of the attributes using the provided metadata on the relation. Instantiates through the factory in order to make sure subclasses and allocation are used if fitting.
18 19 20 21 22 23 24 25 |
# File 'lib/mongoid/relations/builders/embedded/one.rb', line 18 def build(type = nil) return object unless object.is_a?(Hash) if _loading? && base.persisted? Factory.from_db(klass, object) else Factory.build(klass, object) end end |