类:Mongoid::Atomic::Paths::Embedded::Many
- 继承:
-
对象
- 对象
- Mongoid::Atomic::Paths::Embedded::Many
- 定义于:
- lib/mongoid/atomic/paths/embedded/many.rb
Overview
此类封装了查找和更新定义为嵌入式1 -n 的文档的行为。
实例属性摘要
Mongoid::Atomic::Paths::Embedded中包含的属性
#delete_modifier, #document, #insert_modifier, #parent
类方法摘要折叠
实例方法摘要折叠
-
#initialize (文档) ⇒ Many
构造函数
创建新的路径实用程序。
-
#位置⇒ string
获取文档在层次结构中的位置。
Mongoid::Atomic::Paths::Embedded中包含的方法
构造函数详情
#initialize (文档) ⇒ Many
创建新的路径实用程序。
18 19 20 21 |
# File 'lib/mongoid/atomic/paths/embedded/many.rb', line 18 def 初始化(文档) @document, @parent = 文档, 文档._parent @insert_modifier, @delete_modifier = '$push', '$pull' end |
类方法详细信息
。 position_ without_document (parent,association) ⇒ string
获取给定关联的document位置。此函数的使用案例是尝试为嵌入式关联保留空列表。所有用于获取存储 document 位置的现有函数都需要传入要存储的 document,而在尝试存储空列表时,我们没有这样做。
49 50 51 52 |
# File 'lib/mongoid/atomic/paths/embedded/many.rb', line 49 def position_ without_document(父项, 关联) pos = 父项.atomic_position " #{pos} #{'.' 除非 pos.blank?} #{association.store_as} " end |
实例方法详细信息
#位置⇒ string
获取文档在层次结构中的位置。 这将包括可能位于嵌入式关联之上的1 -n 嵌入式关联的索引。
31 32 33 34 35 |
# File 'lib/mongoid/atomic/paths/embedded/many.rb', line 31 def Position pos = 父项.atomic_position 定位器 = 文档.new_record? ? ' ' : " . #{ 文档 ._index } } " "#{pos}#{'.' unless pos.blank?}#{document._association.store_as}#{locator}" end |