Module: Moped::BSON::Extensions::Array

Included in:
Array
Defined in:
lib/moped/bson/extensions/array.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#__bson_dump__(io, key) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/moped/bson/extensions/array.rb', line 7

def __bson_dump__(io, key)
  io << Types::ARRAY
  io << key.to_bson_cstring
  start = io.bytesize
  io << START_LENGTH # write dummy length
  index, length = 0, self.length
  while index < length
    slice(index).__bson_dump__(io, index.to_s)
    index += 1
  end
  io << EOD
  stop = io.bytesize
  io[start, 4] = [stop - start].pack(INT32_PACK)
  io
end