Class: Mongoid::Relations::Bindings::Embedded::Many

Inherits:
Binding
  • Object
show all
Defined in:
lib/mongoid/core_ext/relations/bindings/embedded/many.rb

Instance Method Summary collapse

Instance Method Details

#bind_one(doc) ⇒ Object

Binds a single document with the inverse relation. Used specifically when appending to the proxy.

Examples:

Bind one document.

person.addresses.bind_one(address)

Parameters:

  • doc (Document)

    The single document to bind.

  • options (Hash)

    The binding options.

Since:

  • 2.0.0.rc.1



19
20
21
22
23
24
25
26
# File 'lib/mongoid/core_ext/relations/bindings/embedded/many.rb', line 19

def bind_one(doc)
  doc.parentize(base)
  binding do
    unless .versioned?
      doc.do_or_do_not(.inverse_setter(target), base)
    end
  end
end