Module: Mongo::Protocol::Serializers::Int32 Private
Relationships & Source Files | |
Defined in: | lib/mongo/protocol/serializers.rb |
Overview
MongoDB wire protocol serialization strategy for 32-bit integers.
Serializes and de-serializes one 32-bit integer.
Class Method Summary
-
.deserialize(buffer, options = {}) ⇒ Fixnum
Internal use only
Deserializes a 32-bit Fixnum from the IO stream.
-
.serialize(buffer, value, validating_keys = nil) ⇒ String
Internal use only
Serializes a number to a 32-bit integer.
Class Method Details
.deserialize(buffer, options = {}) ⇒ Fixnum
Deserializes a 32-bit Fixnum from the IO stream
# File 'lib/mongo/protocol/serializers.rb', line 135
def self.deserialize(buffer, = {}) buffer.get_int32 end
.serialize(buffer, value, validating_keys = nil) ⇒ String
Serializes a number to a 32-bit integer
# File 'lib/mongo/protocol/serializers.rb', line 117
def self.serialize(buffer, value, validating_keys = nil) if value.is_a?(BSON::Int32) if value.respond_to?(:value) # bson-ruby >= 4.6.0 value = value.value else value = value.instance_variable_get('@integer') end end buffer.put_int32(value) end