Module: Mongoid::Association::Bindable

Overview

Superclass for all objects that bind associations together.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#_associationObject (readonly)

Returns the value of attribute _association.



11
12
13
# File 'build/mongoid-master/lib/mongoid/association/bindable.rb', line 11

def _association
  @_association
end

#_baseObject (readonly)

Returns the value of attribute _base.



11
12
13
# File 'build/mongoid-master/lib/mongoid/association/bindable.rb', line 11

def _base
  @_base
end

#_targetObject (readonly)

Returns the value of attribute _target.



11
12
13
# File 'build/mongoid-master/lib/mongoid/association/bindable.rb', line 11

def _target
  @_target
end

Instance Method Details

#bindingObject

Execute the provided block inside a binding.

Examples:

Execute the binding block.

binding.binding do
  base.foreign_key = 1
end

Returns:

  • (Object)

    The result of the yield.

Since:

  • 3.0.0



37
38
39
40
41
42
43
# File 'build/mongoid-master/lib/mongoid/association/bindable.rb', line 37

def binding
  unless _binding?
    _binding do
      yield(self) if block_given?
    end
  end
end

#initialize(base, target, association) ⇒ Object

Create the new binding.

Examples:

Initialize a binding.

Binding.new(base, target, association)

Parameters:

Since:

  • 2.0.0.rc.1



23
24
25
# File 'build/mongoid-master/lib/mongoid/association/bindable.rb', line 23

def initialize(base, target, association)
  @_base, @_target, @_association = base, target, association
end