Module: Mongoid::Atomic::Paths::Embedded

Included in:
Many, One
Defined in:
lib/mongoid/atomic/paths/embedded.rb,
lib/mongoid/atomic/paths/embedded/one.rb,
lib/mongoid/atomic/paths/embedded/many.rb

Overview

:nodoc:

Defined Under Namespace

Classes: Many, One

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#delete_modifierObject (readonly)

Returns the value of attribute delete_modifier.



12
13
14
# File 'lib/mongoid/atomic/paths/embedded.rb', line 12

def delete_modifier
  @delete_modifier
end

#documentObject (readonly)

Returns the value of attribute document.



12
13
14
# File 'lib/mongoid/atomic/paths/embedded.rb', line 12

def document
  @document
end

#insert_modifierObject (readonly)

Returns the value of attribute insert_modifier.



12
13
14
# File 'lib/mongoid/atomic/paths/embedded.rb', line 12

def insert_modifier
  @insert_modifier
end

#parentObject (readonly)

Returns the value of attribute parent.



12
13
14
# File 'lib/mongoid/atomic/paths/embedded.rb', line 12

def parent
  @parent
end

Instance Method Details

#pathString

Get the path to the document in the hierarchy.

Examples:

Get the path.

many.path

Returns:

  • (String)

    The path to the document.

Since:

  • 2.1.0



22
23
24
# File 'lib/mongoid/atomic/paths/embedded.rb', line 22

def path
  position.sub(/\.\d+$/, "")
end

#selectorHash

Get the selector to use for the root document when performing atomic updates. When sharding this will include the shard key.

Examples:

Get the selector.

many.selector

Returns:

  • (Hash)

    The selector to identify the document with.

Since:

  • 2.1.0



35
36
37
38
39
# File 'lib/mongoid/atomic/paths/embedded.rb', line 35

def selector
  parent.atomic_selector.
    merge!({ "#{path}._id" => document.identifier || document._id }).
    merge!(document.shard_key_selector)
end