Class Mongoid::Relations::Embedded::One
In: lib/mongoid/relations/embedded/one.rb
Parent: Relations::One

This class defines the behaviour needed for embedded one to one relations.

Methods

new   substitute  

Public Class methods

Instantiate a new embeds_one relation.

@example Create the new proxy.

  One.new(person, name, metadata)

@param [ Document ] base The document this relation hangs off of. @param [ Document ] target The child document in the relation. @param [ Metadata ] metadata The relation‘s metadata

Public Instance methods

Substitutes the supplied target documents for the existing document in the relation.

@example Substitute the new document.

  person.name.substitute(new_name)

@param [ Document ] other A document to replace the target.

@return [ Document, nil ] The relation or nil.

@since 2.0.0.rc.1

[Validate]