Module: Mongoid::Extensions::Hash::Assimilation
- Included in:
- Hash
- Defined in:
- lib/mongoid/extensions/hash/assimilation.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#assimilate(parent, options) ⇒ Object
Introduces a child object into the
Document
object graph.
Instance Method Details
#assimilate(parent, options) ⇒ Object
Introduces a child object into the Document
object graph. This will set up the relationships between the parent and child and update the attributes of the parent Document
.
Options:
parent: The Document
to assimilate into. options: The association Options
for the child.
Example:
{:first_name => "Hank", :last_name => "Moody"}.assimilate(name, options)
Returns: The child Document
.
20 21 22 23 24 |
# File 'lib/mongoid/extensions/hash/assimilation.rb', line 20 def assimilate(parent, ) klass = .klass child = klass.instantiate(self) child.assimilate(parent, ) end |