类:Mongoid::Association::Embedded::EmbedsOne::Proxy
- 定义于:
- lib/mongoid/association/embedded/embeds_one/proxy.rb
Overview
embeds_one 关联的透明代理。 对父文档调用关联 getter 方法时,会返回此类的实例。 该类继承自 Mongoid::Association::Proxy ,并将其大多数方法转发到关联的目标,即子文档。
常量摘要折叠
- VALID_OPTIONS =
定义此关联时的有效选项。
%i[ autobuild 作为 cascade_callbacks 循环 store_as ].冻结
从Proxy继承的常量
实例属性摘要
从Proxy继承的属性
#_association 、 #_base 、 #_target
类方法摘要折叠
-
。 Eager_Loader (associations, Docs ) ⇒ Mongoid::Association::Embedded::Eager
返回此关联的热切加载器。
-
。嵌入式? ⇒ true
如果关联为嵌入式关联,则返回 true。
-
。路径(文档) ⇒ Mongoid::Atomic::Paths::Embedded::One
获取所提供文档的路径计算器。
实例方法摘要折叠
-
#initialize (base, target,association) ⇒ 代理
构造函数
实例化新的 embeds_one 关联。
-
#替换(replacement) ⇒ 文档 | nil
用提供的目标文档替换关联中的现有文档。
从One继承的方法
#__evolve_object_id__ 、 #clear 、 #in_memory 、 #respond_to?
从Proxy继承的方法
apply_ordering 、 #extend_proxies 、 #klass 、 #reset_unloaded 、 #substitutable
包含在封送处理中的方法
构造函数详情
#initialize (base, target,association) ⇒代理
实例化新的 embeds_one 关联。
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/mongoid/association/embedded/embeds_one/proxy.rb', line 33 def 初始化(基础, 目标, 关联) 超 do characterize_one(_target) bind_one characterize_one(_target) update_attributes_hash(_target) _target.保存 if 持久化? _base._reset_memoized_descendants! end end |
类方法详细信息
。 Eager_Loader (associations, Docs ) ⇒ Mongoid::Association::Embedded::Eager
返回此关联的热切加载器。
190 191 192 |
# File 'lib/mongoid/association/embedded/embeds_one/proxy.rb', line 190 def Eager_Loader(关联, docs) Eager.new(关联, docs) end |
。嵌入式? ⇒ true
如果关联为嵌入式关联,则返回 true。 在这种情况下始终为 true。
201 202 203 |
# File 'lib/mongoid/association/embedded/embeds_one/proxy.rb', line 201 def true end |
实例方法详细信息
#替换(replacement) ⇒文档| nil
用提供的目标文档替换关联中的现有文档。
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/mongoid/association/embedded/embeds_one/proxy.rb', line 53 def 替换(替换) return self if 替换 == self if _Assigning? _base.add_atomic_unset(_target) 除非 替换 else update_target_when_not_assing(替换) end unbind_one return nil if replace_with_nil_document(替换) replace_with(替换) self end |