Class: Mongoid::Association::Referenced::HasMany::Binding

Inherits:
Object
  • Object
show all
Includes:
Bindable
Defined in:
build/mongoid-master/lib/mongoid/association/referenced/has_many/binding.rb

Overview

Binding class for has_many associations.

Since:

  • 7.0

Instance Attribute Summary

Attributes included from Bindable

#_association, #_base, #_target

Instance Method Summary collapse

Methods included from Bindable

#binding, #initialize

Instance Method Details

#bind_one(doc) ⇒ Object

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

Examples:

Bind one document.

person.posts.bind_one(post)

Since:

  • 2.0.0.rc.1



20
21
22
23
24
# File 'build/mongoid-master/lib/mongoid/association/referenced/has_many/binding.rb', line 20

def bind_one(doc)
  binding do
    bind_from_relational_parent(doc)
  end
end

#unbind_one(doc) ⇒ Object

Unbind a single document.

Examples:

Unbind the document.

person.posts.unbind_one(document)

Since:

  • 2.0.0.rc.1



32
33
34
35
36
# File 'build/mongoid-master/lib/mongoid/association/referenced/has_many/binding.rb', line 32

def unbind_one(doc)
  binding do
    unbind_from_relational_parent(doc)
  end
end