Module: Mongo::BulkWrite::Validatable Private
Do not use. This module is for internal use only.
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Included In:
| |
Defined in: | lib/mongo/bulk_write/validatable.rb |
Overview
Defines behavior around validations.
Instance Method Summary
-
#validate(name, document) ⇒ Hash, BSON::Document
Internal use only
Validate the document.
- #validate_document(name, document) private Internal use only
- #validate_operation(name) private Internal use only
Instance Method Details
#validate(name, document) ⇒ Hash
, BSON::Document
Validate the document.
# 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
#validate_document(name, document) (private)
# File 'lib/mongo/bulk_write/validatable.rb', line 61
def validate_document(name, document) if document.respond_to?(:keys) || document.respond_to?(:data) document else raise Error::InvalidBulkOperation.new(name, document) end end
#validate_operation(name) (private)
# File 'lib/mongo/bulk_write/validatable.rb', line 69
def validate_operation(name) unless Transformable::MAPPERS.key?(name) raise Error::InvalidBulkOperationType.new(name) end end