类:Mongoid::Association::Referenced::HasOne::Proxy
- 扩展方式:
- 类方法
- 定义于:
- lib/mongoid/association/referenced/has_one/proxy.rb
Overview
has_one 关联的透明代理。 对主题文档调用关联 getter 方法时,将返回此类的实例。 该类继承自 Mongoid::Association::Proxy,并将其大部分方法转发到关联的目标,即必须加载的对方集合上的文档。
在命名空间下定义
模块: 类方法
常量摘要
从Proxy继承的常量
实例属性摘要
从Proxy继承的属性
#_association 、 #_base 、 #_target
实例方法摘要折叠
-
#initialize (base, target,association) ⇒ 代理
构造函数
实例化一个新的references_one关联。
-
# nullify ⇒ 对象
通过删除外键和引用来删除基本文档和目标文档之间的关联,并在此进程中孤立目标文档。
-
# Replacement (replacement) ⇒ One
用提供的目标文档替换关联中的现有文档。
类方法中包含的方法
从One继承的方法
#__evolve_object_id__ 、 #clear 、 #in_memory 、 #respond_to?
从Proxy继承的方法
apply_ordering 、 #extend_proxies 、 #klass 、 #reset_unloaded 、 #substitutable
包含在封送处理中的方法
构造函数详情
#initialize (base, target,association) ⇒代理
实例化一个新的references_one关联。 将在反向对象上设置外键和基数。
43 44 45 46 47 48 49 50 |
# File 'lib/mongoid/association/referenced/has_one/proxy.rb', line 43 def 初始化(基础, 目标, 关联) 超 do Raise_mixed if klass. && !klass.循环? characterize_one(_target) bind_one _target.保存 if 持久化? end end |
实例方法详细信息
# nullify ⇒对象
通过删除外键和引用来删除基本文档和目标文档之间的关联,并在此进程中孤立目标文档。
58 59 60 61 |
# File 'lib/mongoid/association/referenced/has_one/proxy.rb', line 58 def nullify unbind_one _target.保存 end |