2009-12-01 18:55:04 +00:00
|
|
|
# A thin wrapper for the CBson class
|
2010-03-17 19:55:19 +00:00
|
|
|
module Mongo
|
|
|
|
class BSON_C
|
2009-12-01 18:55:04 +00:00
|
|
|
|
2010-03-17 19:55:19 +00:00
|
|
|
def self.serialize(obj, check_keys=false, move_id=false)
|
|
|
|
ByteBuffer.new(CBson.serialize(obj, check_keys, move_id))
|
|
|
|
end
|
2009-12-01 18:55:04 +00:00
|
|
|
|
2010-03-17 19:55:19 +00:00
|
|
|
def self.deserialize(buf=nil)
|
|
|
|
if buf.is_a? String
|
|
|
|
to_deserialize = ByteBuffer.new(buf) if buf
|
|
|
|
else
|
|
|
|
buf = ByteBuffer.new(buf.to_a) if buf
|
|
|
|
end
|
|
|
|
buf.rewind
|
|
|
|
CBson.deserialize(buf.to_s)
|
2009-12-01 18:55:04 +00:00
|
|
|
end
|
|
|
|
|
2010-03-17 19:55:19 +00:00
|
|
|
end
|
2009-12-01 18:55:04 +00:00
|
|
|
end
|