class Mongoid::Atomic::Paths::Embedded::Many
This class encapsulates behavior for locating and updating documents that are defined as an embedded 1-n.
Public Class Methods
new(document)
click to toggle source
Create the new path utility.
@example Create the path util.
Many.new(document)
@param [ Document
] document The document to generate the paths for.
@since 2.1.0
# File lib/mongoid/atomic/paths/embedded/many.rb, line 22 def initialize(document) @document, @parent = document, document._parent @insert_modifier, @delete_modifier ="$push", "$pull" end
Public Instance Methods
position()
click to toggle source
Get the position of the document in the hierarchy. This will include indexes of 1-n embedded associations that may sit above the embedded many.
@example Get the position.
many.position
@return [ String ] The position of the document.
@since 2.1.0
# File lib/mongoid/atomic/paths/embedded/many.rb, line 37 def position pos = parent.atomic_position locator = document.new_record? ? "" : ".#{document._index}" "#{pos}#{"." unless pos.blank?}#{document._association.store_as}#{locator}" end