123456789_123456789_123456789_123456789_123456789_

Class: Mongoid::Atomic::Paths::Embedded::One

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
Inherits: Object
Defined in: 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.

Class Method Summary

Instance Attribute Summary

Instance Method Summary

::Mongoid::Atomic::Paths::Embedded - Included

#path

Get the path to the document in the hierarchy.

Constructor Details

.new(document) ⇒ One

Create the new path utility.

Examples:

Create the path util.

One.new(document)

Parameters:

  • document (Document)

    The document to generate the paths for.

[ GitHub ]

  
# File 'lib/mongoid/atomic/paths/embedded/one.rb', line 20

def initialize(document)
  @document, @parent = document, document._parent
  @insert_modifier, @delete_modifier ="$set", "$unset"
end

Instance Method Details

#positionString

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.

Examples:

Get the position.

one.position

Returns:

  • (String)

    The position of the document.

[ GitHub ]

  
# File 'lib/mongoid/atomic/paths/embedded/one.rb', line 33

def position
  pos = parent.atomic_position
  "#{pos}#{"." unless pos.blank?}#{document._association.store_as}"
end