Method: Mongoid::Traversable#remove_child
- Defined in:
- lib/mongoid/traversable.rb
#remove_child(child) ⇒ Object
Remove a child document from this parent. If an embeds one then set to nil, otherwise remove from the embeds many.
This is called from the RemoveEmbedded persistence command.
357 358 359 360 361 362 363 364 365 366 |
# File 'lib/mongoid/traversable.rb', line 357 def remove_child(child) name = child.association_name if child. attributes.delete(child._association.store_as) remove_ivar(name) else relation = send(name) relation._remove(child) end end |