123456789_123456789_123456789_123456789_123456789_

Class: Mongo::Error::InvalidReplacementDocument

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Error
Instance Chain:
self, Error
Inherits: Error
  • Object
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

Class Method Summary

Constructor Details

.new(key: nil) ⇒ InvalidReplacementDocument

Instantiate the new exception.

Parameters:

  • :key (String)

    The invalid key.

Since:

  • 2.0.0

[ GitHub ]

  
# 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 for internal use only.

Construct the error message.

Parameters:

  • key (String)

    The invalid key.

Returns:

  • (String)

    The error message.

Since:

  • 2.0.0

[ GitHub ]

  
# 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)

This method is for internal use only.

Send and cache the warning.

Since:

  • 2.0.0

[ GitHub ]

  
# File 'lib/mongo/error/invalid_replacement_document.rb', line 42

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