Class: BSON::BSON_C

Inherits:
Object
  • Object
show all
Defined in:
lib/bson/bson_c.rb

Class Method Summary collapse

Class Method Details

.deserialize(buf = nil) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'lib/bson/bson_c.rb', line 27

def self.deserialize(buf=nil)
  if buf.is_a? String
    buf = ByteBuffer.new(buf.unpack("C*")) if buf
  else
    buf = ByteBuffer.new(buf.to_a) if buf
  end
  buf.rewind
  CBson.deserialize(buf.to_s)
end

.serialize(obj, check_keys = false, move_id = false) ⇒ Object



23
24
25
# File 'lib/bson/bson_c.rb', line 23

def self.serialize(obj, check_keys=false, move_id=false)
  ByteBuffer.new(CBson.serialize(obj, check_keys, move_id))
end