Class: Mongoid::Atomic::Paths::Root

Inherits:
Object
  • Object
show all
Defined in:
build/mongoid-7.4/lib/mongoid/atomic/paths/root.rb

Overview

This class encapsulates behavior for locating and updating root documents atomically.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(document) ⇒ Root

Create the new root path utility.

Examples:

Create the root path util.

Root.new(document)

Parameters:

  • document (Document)

    The document to generate the paths for.



19
20
21
# File 'build/mongoid-7.4/lib/mongoid/atomic/paths/root.rb', line 19

def initialize(document)
  @document, @path, @position = document, "", ""
end

Instance Attribute Details

#documentObject (readonly)

Returns the value of attribute document.



11
12
13
# File 'build/mongoid-7.4/lib/mongoid/atomic/paths/root.rb', line 11

def document
  @document
end

#pathObject (readonly)

Returns the value of attribute path.



11
12
13
# File 'build/mongoid-7.4/lib/mongoid/atomic/paths/root.rb', line 11

def path
  @path
end

#positionObject (readonly)

Returns the value of attribute position.



11
12
13
# File 'build/mongoid-7.4/lib/mongoid/atomic/paths/root.rb', line 11

def position
  @position
end

Instance Method Details

#insert_modifierObject

Asking for the insert modifier on a document with a root path indicates a mixed association most likely happened.

Examples:

Attempt to get the insert modifier.

root.insert_modifier

Raises:



30
31
32
# File 'build/mongoid-7.4/lib/mongoid/atomic/paths/root.rb', line 30

def insert_modifier
  raise Errors::InvalidPath.new(document.class)
end