Module: BSON::Array::ClassMethods

Defined in:
lib/bson/array.rb

Overview

Since:

  • 2.0.0

Instance Method Summary collapse

Instance Method Details

#from_bson(bson) ⇒ Array

Deserialize the array from BSON.

Parameters:

  • bson (BSON)

    The bson representing an array.

Returns:

  • (Array)

    The decoded array.

See Also:

Since:

  • 2.0.0



94
95
96
97
98
99
100
101
102
# File 'lib/bson/array.rb', line 94

def from_bson(bson)
  array = new
  bson.read(4) # throw away the length
  while (type = bson.readbyte.chr) != NULL_BYTE
    bson.gets(NULL_BYTE)
    array << BSON::Registry.get(type).from_bson(bson)
  end
  array
end