模块:Mongoid::Association::Bindable

Overview

将关联绑定在一起的所有对象的超类。

实例属性摘要折叠

实例方法摘要折叠

实例属性详细信息

# _association对象(只读)

返回属性 _association 的值。



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

def _association
  @_association
end

# _base对象(只读)

返回属性 _base 的值。



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

def _base
  @_base
end

# _target对象(只读)

返回属性 _target 的值。



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

def _target
  @_target
end

实例方法详细信息

#绑定对象

在绑定内执行提供的区块。

例子:

执行绑定块。

binding.binding do
  base.foreign_key = 1
end

返回:

  • ( Object )

    收益率的结果。



33
34
35
36
37
38
39
# File 'lib/mongoid/association/bindable.rb', line 33

def 绑定
  除非 _绑定?
    _bounding do
      产量(self) if block_given?
    end
  end
end

#initialize (base, target,association) ⇒对象

创建新绑定。

例子:

初始化绑定。

Binding.new(base, target, association)

参数:



21
22
23
# File 'lib/mongoid/association/bindable.rb', line 21

def 初始化(基础, 目标, 关联)
  @_base, @_target, @_association = 基础, 目标, 关联
end