Class | Mongoid::Relations::Referenced::One |
In: |
lib/mongoid/relations/referenced/one.rb
|
Parent: | Relations::One |
This class defines the behaviour for all relations that are a one-to-one between documents in different collections.
Instantiate a new references_one relation. Will set the foreign key and the base on the inverse object.
@example Create the new relation.
Referenced::One.new(base, target, metadata)
@param [ Document ] base The document this relation hangs off of. @param [ Document ] target The target (child) of the relation. @param [ Metadata ] metadata The relation‘s metadata.
Removes the association between the base document and the target document by deleting the foreign key and the reference, orphaning the target document in the process.
@example Nullify the relation.
person.game.nullify
@since 2.0.0.rc.1
Substitutes the supplied target document for the existing document in the relation. If the new target is nil, perform the necessary deletion.
@example Replace the relation.
person.game.substitute(new_game)
@param [ Array<Document> ] replacement The replacement target.
@return [ One ] The relation.
@since 2.0.0.rc.1