From 765ed9334e02d108e4c032e2ecd52e199826c5ff Mon Sep 17 00:00:00 2001 From: Mike Dirolf Date: Wed, 4 Mar 2009 11:16:28 -0500 Subject: [PATCH] do to_a if it's not a string --- lib/mongo/util/bson.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/mongo/util/bson.rb b/lib/mongo/util/bson.rb index adc7bba..7f5d132 100644 --- a/lib/mongo/util/bson.rb +++ b/lib/mongo/util/bson.rb @@ -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