In Files

Methods

BSON::Hash::ClassMethods

Public Instance Methods

from_bson(bson) click to toggle source

Deserialize the hash from BSON.

@param [ IO ] bson The bson representing a hash.

@return [ Array ] The decoded hash.

@see bsonspec.org/#/specification

@since 2.0.0

# File lib/bson/hash.rb, line 62
def from_bson(bson)
  hash = new
  bson.read(4) # Swallow the first four bytes.
  while (type = bson.readbyte.chr) != NULL_BYTE
    field = bson.gets(NULL_BYTE).from_bson_string.chop!
    hash[field] = BSON::Registry.get(type).from_bson(bson)
  end
  hash
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.