a9b3c8e7a5
- changed the BSON constant to BSON_CODER and scoped it inside of a module - changed the directory layout for all of the BSON related files - updated the C extension to find the BSON files at their new directory locations - updated the C extension to use better/safer macros for accessing the C API; extension now compiles cleanly under rubinius/rbx - changed directory layout for BSON related tests - modified the Rakefile to understand the new layout
21 lines
449 B
Ruby
21 lines
449 B
Ruby
# A thin wrapper for the CBson class
|
|
module Mongo
|
|
class BSON_C
|
|
|
|
def self.serialize(obj, check_keys=false, move_id=false)
|
|
ByteBuffer.new(CBson.serialize(obj, check_keys, move_id))
|
|
end
|
|
|
|
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)
|
|
end
|
|
|
|
end
|
|
end
|