do to_a if it's not a string

This commit is contained in:
Mike Dirolf 2009-03-04 11:16:28 -05:00
parent 3a3109e7dc
commit 765ed9334e
1 changed files with 5 additions and 1 deletions

View File

@ -134,7 +134,11 @@ class BSON
def deserialize(buf=nil, parent=nil)
# If buf is nil, use @buf, assumed to contain already-serialized BSON.
# This is only true during testing.
@buf = ByteBuffer.new(buf) if buf
if buf.is_a? String
@buf = ByteBuffer.new(buf) if buf
else
@buf = ByteBuffer.new(buf.to_a) if buf
end
@buf.rewind
@buf.get_int # eat message size
doc = OrderedHash.new