模块:Mongoid::Association::Options
- 包含在:
- Relatable
- 定义于:
- lib/mongoid/association/options.rb
Overview
用于所有关联类型的选项上下文。
实例方法摘要折叠
-
#as ⇒ String | Symbol
返回多态子文档的父文档名称。
-
# autobuild? ⇒ true | false
关联是否为自动构建。
-
# autosave ⇒ true | false (也:#autosave?)
用于在保存父对象时保存任何已加载成员并销毁标记为销毁的成员的选项。
-
# cascading_callbacks? ⇒ true | false
关联是否具有从父级向下级联的回调。
-
# counter_cached? ⇒ true | false
是否对关联进行计数器缓存。
-
#循环? ⇒ true | false
关联是否为循环关联。
-
#依赖⇒ string
指定当所有者被销毁时关联对象会发生什么情况。
-
#forced_nil_inverse? ⇒ false
关联是否强制执行 nil inverse(因此不保存外键)。
-
#已索引? ⇒ true | false
是否对主节点 (primary node in the replica set)键字段或外键字段进行索引。
-
#inverse_of ⇒ String
所属对象用来引用此关联的名称。
-
#order ⇒ Criteria::Queryable::Key
关联上的自定义排序选项。
-
#多态? ⇒ true | false
此关联是否为多态。
-
#primary_key ⇒ 符号 | string
Mongoid 假定用于保存关联主键的字段是ID 。
-
#store_as ⇒ nil
store_as 选项。
-
# touch_field ⇒ nil
用于保存关联对象类型的字段。
-
# touchable? ⇒ true | false
private
更新反向对象时,是否应自动触及关联对象。
-
#type ⇒ nil
用于保存关联对象类型的字段。
实例方法详细信息
#as ⇒ String | Symbol
返回多态子文档的父文档名称。
13 14 15 |
# File 'lib/mongoid/association/options.rb', line 13 def 作为 @options[:as] end |
# autobuild? ⇒ true | false
关联是否为自动构建。
41 42 43 |
# File 'lib/mongoid/association/options.rb', line 41 def 自动构建? !!@options[:autobuild] end |
# autosave ⇒ true | false也称为: autosave?
用于在保存父对象时保存任何已加载成员并销毁标记为销毁的成员的选项。
71 72 73 |
# File 'lib/mongoid/association/options.rb', line 71 def autosave !!@options[:autosave] end |
# cascading_callbacks? ⇒ true | false
关联是否具有从父级向下级联的回调。
91 92 93 |
# File 'lib/mongoid/association/options.rb', line 91 def cascading_callbacks? !!@options[:cascade_callbacks] end |
# counter_cached? ⇒ true | false
是否对关联进行计数器缓存。
79 80 81 |
# File 'lib/mongoid/association/options.rb', line 79 def counter_cached? !!@options[:counter_cache] end |
#循环? ⇒ true | false
关联是否为循环关联。
48 49 50 |
# File 'lib/mongoid/association/options.rb', line 48 def 循环? !!@options[:循环] end |
#依赖⇒ string
指定当所有者被销毁时关联对象会发生什么情况。
20 21 22 |
# File 'lib/mongoid/association/options.rb', line 20 def 依赖 @options[:depend] end |
#forced_nil_inverse? ⇒ false
关联是否强制执行 nil inverse(因此不保存外键)。
103 |
# File 'lib/mongoid/association/options.rb', line 103 def forced_nil_inverse?; false; end |
#已索引? ⇒ true | false
是否对主节点 (primary node in the replica set)键字段或外键字段进行索引。
34 35 36 |
# File 'lib/mongoid/association/options.rb', line 34 def 索引? @indexed ||= !!@options[:index] end |
# inverse_of ⇒ string
所属对象用来引用此关联的名称。
55 56 57 |
# File 'lib/mongoid/association/options.rb', line 55 def inverse_of @options[:inverse_of] end |
#order ⇒ Criteria::Queryable::Key
关联上的自定义排序选项。
27 28 29 |
# File 'lib/mongoid/association/options.rb', line 27 def 来自一个购物车应用的order文档, @options[:order] end |
#多态? ⇒ true | false
此关联是否为多态。
86 |
# File 'lib/mongoid/association/options.rb', line 86 def 多态?; false; end |
#primary_key ⇒符号 | string
Mongoid 假定用于保存关联主键的字段是ID 。 您可以覆盖此设置并使用 :primary_key 选项显式指定主键。
63 64 65 |
# File 'lib/mongoid/association/options.rb', line 63 def primary_key @primary_key ||= @options[:primary_key] ? @options[:primary_key].to_s : Relatable::PRIMARY_KEY_DEFAULT end |
#store_as ⇒ nil
store_as 选项。
98 |
# File 'lib/mongoid/association/options.rb', line 98 def store_as; end |
# touch_field ⇒ nil
用于保存关联对象类型的字段。
113 114 115 |
# File 'lib/mongoid/association/options.rb', line 113 def touch_field @touch_field ||= [:touch] if ([:touch].is_a?(字符串) || [:touch].is_a?(符号)) end |
# touchable? ⇒ true | false
此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。
更新反向对象时,是否应自动触及关联对象。
124 125 126 |
# File 'lib/mongoid/association/options.rb', line 124 def touchable? !!@options[:touch] end |
#type ⇒ nil
用于保存关联对象类型的字段。
108 |
# File 'lib/mongoid/association/options.rb', line 108 def 类型; end |