Class: Mongoid::Atomic::Paths::Embedded::One
- Inherits:
-
Object
- Object
- Mongoid::Atomic::Paths::Embedded::One
- Includes:
- Mongoid::Atomic::Paths::Embedded
- Defined in:
- build/mongoid-7.3/lib/mongoid/atomic/paths/embedded/one.rb
Overview
This class encapsulates behavior for locating and updating documents that are defined as an embedded 1-1.
Instance Attribute Summary
Attributes included from Mongoid::Atomic::Paths::Embedded
#delete_modifier, #document, #insert_modifier, #parent
Instance Method Summary collapse
-
#initialize(document) ⇒ One
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) ⇒ One
Create the new path utility.
22 23 24 25 |
# File 'build/mongoid-7.3/lib/mongoid/atomic/paths/embedded/one.rb', line 22 def initialize(document) @document, @parent = document, document._parent @insert_modifier, @delete_modifier ="$set", "$unset" end |
Instance Method Details
#position ⇒ String
Get the position of the document in the hierarchy. This will include indexes of 1-n embedded associations that may sit above the embedded one.
37 38 39 40 |
# File 'build/mongoid-7.3/lib/mongoid/atomic/paths/embedded/one.rb', line 37 def position pos = parent.atomic_position "#{pos}#{"." unless pos.blank?}#{document._association.store_as}" end |