Module: BSON::Array::ClassMethods

Defined in:
lib/bson/array.rb

Overview

Class-level methods to be added to the Array class.

Since:

  • 2.0.0

Instance Method Summary collapse

Instance Method Details

#from_bson(buffer, **options) ⇒ Array

Note:

If the argument cannot be parsed, an exception will be raised and the argument will be left in an undefined state. The caller must explicitly call ‘rewind` on the buffer before trying to parse it again.

Deserialize the array from BSON.

Parameters:

  • buffer (ByteBuffer)

    The byte buffer.

  • options (Hash)

    a customizable set of options

Options Hash (**options):

  • :mode (nil | :bson)

    Decoding mode to use.

Returns:

  • (Array)

    The decoded array.

See Also:

Since:

  • 2.0.0



126
127
128
129
130
131
132
# File 'lib/bson/array.rb', line 126

def from_bson(buffer, **options)
  if buffer.respond_to?(:get_array)
    buffer.get_array(**options)
  else
    parse_array_from_buffer(buffer, **options)
  end
end