クラス: Mongoid::関連付け::参照::BelongsTo::Binding

継承:
オブジェクト
  • オブジェクト
すべて表示
次のことが含まれます。
バインディング可能
定義:
lib/mongoid/関連付け/referenced/belongs_to/bining.rb

Overview

include_to 関連付けのバインディング クラス。

インスタンス属性の概要

バインディング可能なに含まれる属性

#_association, #_base, #_target

インスタンス メソッドの概要を折りたたむ

バインド可能な に含まれるメソッド

バインディング初期化

インスタンス メソッドの詳細

# bind_one =オブジェクト

基本オブジェクトを関連付けの逆にバインドします。 したがって、両方の側で実際のオブジェクト自体を参照します。

この場合、ドキュメント自体と逆オブジェクトの関連付けを設定します。

例:

ドキュメントをバインドします。

game.person.bind(:continue => true)
game.person = Person.new


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# ファイル 'lib/mongoid/関連付け/referenced/belongs_to/bining.rb' の検索行は20です

デフォルト bind_one
  バインディング 行う
    checkpoint_polytric_inverses.(_ target)
    bind_foreign_key(_base, Record_id(_ target))

    # 逆のタイプを設定します(例: 新しい多形関連付けの "#{name}_type")
    場合 _関連付け.inverse_type & & !_base.frozen?
      キー = _関連付け.リゾルバ.default_key_for(_ target)
      bind_polytric_inverse_type(_base, キー)
    end

    場合 ( = _関連付け.(_ target)) & & set_base_関連付け
      場合 _base.referenced_many?
        _ target.__send__().プッシュ(_base)
      else
        排除_関連付け(_ target)
        _ target.set_relation(, _base)
      end
    end
  end
end

#unbind_one =オブジェクト

参照を nil に設定することで、基本オブジェクトとその逆のバインドを解除します。

例:

ドキュメントのバインドを解除します。

game.person.unbind(:continue => true)
game.person = nil


48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# ファイル 'lib/mongoid/関連付け/referenced/belongs_to/bining.rb' の検索行は48です

デフォルト unbind_one
  バインディング 行う
     = _関連付け.(_ target)
    bind_foreign_key(_base, nil)
    bind_polytric_inverse_type(_base, nil)
    場合 
      set_base_関連付け
      場合 _base.referenced_many?
        _ target.__send__().削除(_base)
      else
        _ target.set_relation(, nil)
      end
    end
  end
end