Class: Mongo::Error::InvalidReplacementDocument

Inherits:
Error
  • Object
show all
Defined in:
lib/mongo/error/invalid_replacement_document.rb

Overview

Exception raised if the object is not a valid replacement document.

Since:

  • 2.0.0

Constant Summary collapse

MESSAGE =
Deprecated.

The error message.

Since:

  • 2.0.0

'Invalid replacement document provided'

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key: nil) ⇒ InvalidReplacementDocument

Instantiate the new exception.

Parameters:

  • :key (String)

    The invalid key.

Since:

  • 2.0.0



52
53
54
# File 'lib/mongo/error/invalid_replacement_document.rb', line 52

def initialize(key: nil)
  super(self.class.message(key))
end

Class Method Details

.message(key) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Construct the error message.

Parameters:

  • key (String)

    The invalid key.

Returns:

  • (String)

    The error message.

Since:

  • 2.0.0



33
34
35
36
37
# File 'lib/mongo/error/invalid_replacement_document.rb', line 33

def self.message(key)
  message = 'Invalid replacement document provided. Replacement documents '
  message += "must not contain atomic modifiers. The \"#{key}\" key is invalid."
  message
end

.warn(logger, key) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Send and cache the warning.

Since:

  • 2.0.0



42
43
44
45
46
47
# File 'lib/mongo/error/invalid_replacement_document.rb', line 42

def self.warn(logger, key)
  @warned ||= begin
    logger.warn(message(key))
    true
  end
end