module Moped::BSON::Extensions::Array

Public Instance Methods

__bson_dump__(io, key) click to toggle source
# 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