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 behavior 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



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/mongo/bulk_write/validatable.rb', line 43

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

  if document.respond_to?(:keys) && document[:array_filters]
    @has_array_filters = true
  end

  if document.respond_to?(:keys) && document[:hint]
    @has_hint = true
  end
end