lib/mongo/util/bson.rb in mongo-0.16 vs lib/mongo/util/bson.rb in mongo-0.17

- old
+ new

@@ -69,10 +69,16 @@ def to_a @buf.to_a end + # Serializes an object. + # Implemented to ensure an API compatible with BSON extension. + def self.serialize(obj, check_keys) + new.serialize(obj, check_keys) + end + begin require 'mongo_ext/cbson' def serialize(obj, check_keys=false) @buf = ByteBuffer.new(CBson.serialize(obj, check_keys)) end @@ -95,9 +101,15 @@ serialize_eoo_element(@buf) @buf.put_int(@buf.size, 0) self end + end + + # Returns the array stored in the buffer. + # Implemented to ensure an API compatible with BSON extension. + def unpack(arg) + @buf.to_a end def serialize_key_value(k, v, check_keys) k = k.to_s if check_keys