lib/mongo/protocol/serializers.rb in mongo-2.10.2 vs lib/mongo/protocol/serializers.rb in mongo-2.10.3

- old
+ new

@@ -100,17 +100,20 @@ # MongoDB wire protocol serialization strategy for 32-bit integers. # # Serializes and de-serializes one 32-bit integer. module Int32 - # Serializes a fixnum to a 4-byte 32-bit integer + # Serializes a number to a 32-bit integer # # @param buffer [ String ] Buffer to receive the serialized Int32. - # @param value [ Fixnum ] 32-bit integer to be serialized. + # @param value [ Integer | BSON::Int32 ] 32-bit integer to be serialized. # # @return [String] Buffer with serialized value. def self.serialize(buffer, value, validating_keys = BSON::Config.validating_keys?) + if value.is_a?(BSON::Int32) + value = value.value + end buffer.put_int32(value) end # Deserializes a 32-bit Fixnum from the IO stream # @@ -125,16 +128,19 @@ # MongoDB wire protocol serialization strategy for 64-bit integers. # # Serializes and de-serializes one 64-bit integer. module Int64 - # Serializes a fixnum to an 8-byte 64-bit integer + # Serializes a number to a 64-bit integer # # @param buffer [ String ] Buffer to receive the serialized Int64. - # @param value [ Fixnum ] 64-bit integer to be serialized. + # @param value [ Integer | BSON::Int64 ] 64-bit integer to be serialized. # # @return [ String ] Buffer with serialized value. def self.serialize(buffer, value, validating_keys = BSON::Config.validating_keys?) + if value.is_a?(BSON::Int64) + value = value.value + end buffer.put_int64(value) end # Deserializes a 64-bit Fixnum from the IO stream #