Module: Moped::BSON::Extensions::Hash::ClassMethods

Included in:
Hash
Defined in:
lib/moped/bson/extensions/hash.rb

Instance Method Summary collapse

Instance Method Details

#__bson_load__(io, doc = new) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/moped/bson/extensions/hash.rb', line 25

def __bson_load__(io, doc = new)
  io.read(4) # Swallow the first four (length) bytes
  while (buf = io.readbyte) != 0
    key = io.gets(NULL_BYTE).from_utf8_binary.chop!
    if native_class = Types::MAP[buf]
      doc[key] = native_class.__bson_load__(io)
    end
  end
  doc
end