Module: BSON::Hash::ClassMethods

Defined in:
lib/bson/hash.rb

Overview

Since:

  • 2.0.0

Instance Method Summary collapse

Instance Method Details

#from_bson(buffer) ⇒ Array

Deserialize the hash from BSON.

Parameters:

Returns:

  • (Array)

    The decoded hash.

See Also:

Since:

  • 2.0.0



75
76
77
78
79
80
81
82
83
# File 'lib/bson/hash.rb', line 75

def from_bson(buffer)
  hash = Document.allocate
  buffer.get_int32 # Throw away the size.
  while (type = buffer.get_byte) != NULL_BYTE
    field = buffer.get_cstring
    hash.store(field, BSON::Registry.get(type, field).from_bson(buffer))
  end
  hash
end