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

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

Overview

Binding class for has_many associations.

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)


18
19
20
21
22
# File 'lib/mongoid/association/referenced/has_many/binding.rb', line 18

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)


28
29
30
31
32
# File 'lib/mongoid/association/referenced/has_many/binding.rb', line 28

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