Method: Mongo::Protocol::Serializers::BitVector#serialize

Defined in:
lib/mongo/protocol/bit_vector.rb

#serialize(buffer, value, 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 vector by encoding each symbol according to its mask

Parameters:

  • buffer (String)

    Buffer to receive the serialized vector

  • value (Array<Symbol>)

    Array of flags to encode

  • validating_keys (true, false) (defaults to: nil)

    Whether keys should be validated when serializing. This option is deprecated and will not be used. It will removed in version 3.0.

Returns:

  • (String)

    Buffer that received the serialized vector



46
47
48
49
50
# File 'lib/mongo/protocol/bit_vector.rb', line 46

def serialize(buffer, value, validating_keys = nil)
  bits = 0
  value.each { |flag| bits |= (@masks[flag] || 0) }
  buffer.put_int32(bits)
end