Module: Mongo::Protocol::Serializers::Document Private
- Defined in:
- build/ruby-driver-v2.19/lib/mongo/protocol/serializers.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.
MongoDB wire protocol serialization strategy for a BSON Document.
Serializes and de-serializes a single document.
Class Method Summary collapse
-
.deserialize(buffer, options = {}) ⇒ Hash
private
Deserializes a document from the IO stream.
-
.serialize(buffer, value, max_bson_size = nil, validating_keys = nil) ⇒ String
private
Serializes a document into the buffer.
-
.size_limited? ⇒ true
private
Whether there can be a size limit on this type after serialization.
Class Method Details
.deserialize(buffer, options = {}) ⇒ Hash
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.
Deserializes a document from the IO stream
384 385 386 387 |
# File 'build/ruby-driver-v2.19/lib/mongo/protocol/serializers.rb', line 384 def self.deserialize(buffer, = {}) mode = [:deserialize_as_bson] ? :bson : nil BSON::Document.from_bson(buffer, **{ mode: mode }) end |
.serialize(buffer, value, max_bson_size = nil, validating_keys = nil) ⇒ 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.
Serializes a document into the buffer
364 365 366 367 368 369 370 371 372 |
# File 'build/ruby-driver-v2.19/lib/mongo/protocol/serializers.rb', line 364 def self.serialize(buffer, value, max_bson_size = nil, validating_keys = nil) start_size = buffer.length value.to_bson(buffer) serialized_size = buffer.length - start_size if max_bson_size && serialized_size > max_bson_size raise Error::MaxBSONSize, "The document exceeds maximum allowed BSON object size after serialization. Serialized size: #{serialized_size} bytes, maximum allowed size: #{max_bson_size} bytes" end end |
.size_limited? ⇒ true
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.
Whether there can be a size limit on this type after serialization.
394 395 396 |
# File 'build/ruby-driver-v2.19/lib/mongo/protocol/serializers.rb', line 394 def self.size_limited? true end |