Module: Mongo::Protocol::Serializers::Document Private
- Defined in:
- 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) ⇒ Hash
private
Deserializes a document from the IO stream.
-
.serialize(buffer, value, max_bson_size = nil, validating_keys = BSON::Config.validating_keys?) ⇒ 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) ⇒ 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
337 338 339 |
# File 'lib/mongo/protocol/serializers.rb', line 337 def self.deserialize(buffer) BSON::Document.from_bson(buffer) end |
.serialize(buffer, value, max_bson_size = nil, validating_keys = BSON::Config.validating_keys?) ⇒ 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
324 325 326 327 328 329 330 |
# File 'lib/mongo/protocol/serializers.rb', line 324 def self.serialize(buffer, value, max_bson_size = nil, validating_keys = BSON::Config.validating_keys?) start_size = buffer.length value.to_bson(buffer, validating_keys) if max_bson_size && buffer.length - start_size > max_bson_size raise Error::MaxBSONSize.new(max_bson_size) 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.
346 347 348 |
# File 'lib/mongo/protocol/serializers.rb', line 346 def self.size_limited? true end |