Module: Mongo::BulkWrite::Validatable Private

Included in:
OrderedCombiner, UnorderedCombiner
Defined in:
lib/mongo/bulk_write/validatable.rb

Overview

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

Defines behaviour around validations.

Since:

  • 2.1.0

Instance Method Summary collapse

Instance Method Details

#validate(name, document) ⇒ Hash, BSON::Document

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.

Validate the document.

Examples:

Validate the document.

validatable.validate(:insert_one, { _id: 0 })

Parameters:

  • name (Symbol)

    The operation name.

  • document (Hash, BSON::Document)

    The document.

Returns:

  • (Hash, BSON::Document)

    The document.

Raises:

  • (InvalidBulkOperation)

    If not valid.

Since:

  • 2.1.0



40
41
42
43
44
45
46
# File 'lib/mongo/bulk_write/validatable.rb', line 40

def validate(name, document)
  validate_operation(name)
  validate_document(name, document)
  if document.respond_to?(:keys) && (document[:collation] || document[Operation::COLLATION])
    @has_collation = true
  end
end