Class: Mongoid::Atomic::Paths::Embedded::Many
- Includes:
- Mongoid::Atomic::Paths::Embedded
- Defined in:
- lib/mongoid/atomic/paths/embedded/many.rb
Overview
This class encapsulates behaviour for locating and updating documents that are defined as an embedded 1-n.
Instance Attribute Summary
Attributes included from Mongoid::Atomic::Paths::Embedded
#delete_modifier, #document, #insert_modifier, #parent
Instance Method Summary collapse
-
#initialize(document) ⇒ Many
constructor
Create the new path utility.
-
#position ⇒ String
Get the position of the document in the hierarchy.
Methods included from Mongoid::Atomic::Paths::Embedded
Constructor Details
#initialize(document) ⇒ Many
Create the new path utility.
20 21 22 23 |
# File 'lib/mongoid/atomic/paths/embedded/many.rb', line 20 def initialize(document) @document, @parent = document, document._parent @insert_modifier, @delete_modifier ="$push", "$pull" end |
Instance Method Details
#position ⇒ String
Get the position of the document in the hierarchy. This will include indexes of 1-n embedded relations that may sit above the embedded many.
35 36 37 38 39 |
# File 'lib/mongoid/atomic/paths/embedded/many.rb', line 35 def position pos = parent.atomic_position locator = document.new? ? "" : ".#{document._index}" "#{pos}#{"." unless pos.blank?}#{document..name}#{locator}" end |