A byte buffer.
A thin wrapper for the CBson class
A hash in which the order of keys are preserved.
Under Ruby 1.9 and greater, this class has no added methods because Ruby's Hash already keeps its keys ordered by order of insertion.
# File lib/bson/types/object_id.rb, line 7 def BSON::ObjectId(s) ObjectId.from_string(s) end
# File lib/bson.rb, line 8 def self.deserialize(buf=nil) BSON_CODER.deserialize(buf) end
# File lib/bson.rb, line 28 def self.extension? !((ENV.key?('BSON_EXT_DISABLED') && RUBY_PLATFORM =~ /java/) || (ENV.key?('BSON_EXT_DISABLED') || "\x01\x00\x00\x00".unpack("i")[0] != 1)) end
Reads a single BSON document from an IO object. This method is used in the executable b2json, bundled with the bson gem, for reading a file of bson documents.
@param [IO] io an io object containing a bson object.
@return [ByteBuffer]
# File lib/bson.rb, line 19 def self.read_bson_document(io) bytebuf = BSON::ByteBuffer.new sz = io.read(4).unpack("V")[0] bytebuf.put_int(sz) bytebuf.put_array(io.read(sz-4).unpack("C*")) bytebuf.rewind return BSON.deserialize(bytebuf) end
Generated with the Darkfish Rdoc Generator 2.