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

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

Overview

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

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Root) initialize(document)

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.

Since:

  • 2.1.0



20
21
22
# File 'lib/mongoid/atomic/paths/root.rb', line 20

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

Instance Attribute Details

- (Object) document (readonly)

Returns the value of attribute document



10
11
12
# File 'lib/mongoid/atomic/paths/root.rb', line 10

def document
  @document
end

- (Object) path (readonly)

Returns the value of attribute path



10
11
12
# File 'lib/mongoid/atomic/paths/root.rb', line 10

def path
  @path
end

- (Object) position (readonly)

Returns the value of attribute position



10
11
12
# File 'lib/mongoid/atomic/paths/root.rb', line 10

def position
  @position
end

Instance Method Details

- (Object) insert_modifier

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

Examples:

Attempt to get the insert modifier.

root.insert_modifier

Raises:

Since:

  • 3.0.14



33
34
35
# File 'lib/mongoid/atomic/paths/root.rb', line 33

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