模块: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
返回多态子文档的父文档名称。
10 11 12 |
# File 'lib/mongoid/association/options.rb', line 10 def 作为 @options[:as] end |
# autobuild? ⇒ true | false
关联是否为自动构建。
38 39 40 |
# File 'lib/mongoid/association/options.rb', line 38 def 自动构建? !!@options[:autobuild] end |
# autosave ⇒ true | false也称为: autosave?
用于在保存父对象时保存任何已加载成员并销毁标记为销毁的成员的选项。
68 69 70 |
# File 'lib/mongoid/association/options.rb', line 68 def autosave !!@options[:autosave] end |
# cascading_callbacks? ⇒ true | false
关联是否具有从父级向下级联的回调。
90 91 92 |
# File 'lib/mongoid/association/options.rb', line 90 def cascading_callbacks? !!@options[:cascade_callbacks] end |
# counter_cached? ⇒ true | false
是否对关联进行计数器缓存。
76 77 78 |
# File 'lib/mongoid/association/options.rb', line 76 def counter_cached? !!@options[:counter_cache] end |
#循环? ⇒ true | false
关联是否为循环关联。
45 46 47 |
# File 'lib/mongoid/association/options.rb', line 45 def 循环? !!@options[:循环] end |
#依赖⇒ string
指定当所有者被销毁时关联对象会发生什么情况。
17 18 19 |
# File 'lib/mongoid/association/options.rb', line 17 def 依赖 @options[:depend] end |
#forced_nil_inverse? ⇒ false
关联是否强制执行 nil inverse(因此不保存外键)。
102 103 104 |
# File 'lib/mongoid/association/options.rb', line 102 def forced_nil_inverse? false end |
#已索引? ⇒ true | false
是否对主节点 (primary node in the replica set)键字段或外键字段进行索引。
31 32 33 |
# File 'lib/mongoid/association/options.rb', line 31 def 索引? @indexed ||= !!@options[:index] end |
# inverse_of ⇒ string
所属对象用来引用此关联的名称。
52 53 54 |
# File 'lib/mongoid/association/options.rb', line 52 def inverse_of @options[:inverse_of] end |
#order ⇒ Criteria::Queryable::Key
关联上的自定义排序选项。
24 25 26 |
# File 'lib/mongoid/association/options.rb', line 24 def 来自一个购物车应用的order文档, @options[:order] end |
#多态? ⇒ true | false
此关联是否为多态。
83 84 85 |
# File 'lib/mongoid/association/options.rb', line 83 def 多态? false end |
#primary_key ⇒符号 | string
Mongoid 假定用于保存关联主键的字段是ID 。 您可以覆盖此设置并使用 :primary_key 选项显式指定主键。
60 61 62 |
# File 'lib/mongoid/association/options.rb', line 60 def primary_key @primary_key ||= @options[:primary_key] ? @options[:primary_key].to_s : Relatable::PRIMARY_KEY_DEFAULT end |
#store_as ⇒ nil
store_as 选项。
97 |
# File 'lib/mongoid/association/options.rb', line 97 def store_as; end |
# touch_field ⇒ nil
用于保存关联对象类型的字段。
114 115 116 |
# File 'lib/mongoid/association/options.rb', line 114 def touch_field @touch_field ||= [:touch] if [:touch].is_a?(字符串) || [:touch].is_a?(符号) end |
# touchable? ⇒ true | false
此方法是私有 API 的一部分。 您应尽可能避免使用此方法,因为它将来可能会被删除或更改。
更新反向对象时,是否应自动触及关联对象。
125 126 127 |
# File 'lib/mongoid/association/options.rb', line 125 def touchable? !!@options[:touch] end |
#type ⇒ nil
用于保存关联对象类型的字段。
109 |
# File 'lib/mongoid/association/options.rb', line 109 def 类型; end |