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

Inherits:
Object
  • Object
show all
Includes:
Bindable
Defined in:
build/mongoid-8.1/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)


17
18
19
20
21
# File 'build/mongoid-8.1/lib/mongoid/association/referenced/has_many/binding.rb', line 17

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)


27
28
29
30
31
# File 'build/mongoid-8.1/lib/mongoid/association/referenced/has_many/binding.rb', line 27

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