cleanup; raise different for known but unimplemented types

This commit is contained in:
Jim Menard 2008-12-16 06:57:13 -05:00
parent 80c0302307
commit a3db5e6924
1 changed files with 13 additions and 11 deletions

View File

@ -3,28 +3,28 @@ require 'mongo/util/ordered_hash'
require 'mongo/objectid' require 'mongo/objectid'
# See http://github.com/10gen/mongo/tree/master/db/jsobj.h # See http://github.com/10gen/mongo/tree/master/db/jsobj.h
# and
class BSON class BSON
EOO = 0 # x MINKEY = -1
MAXKEY = -1 # x EOO = 0
NUMBER = 1 # x t NUMBER = 1
STRING = 2 # x t STRING = 2
OBJECT = 3 # x t OBJECT = 3
ARRAY = 4 ARRAY = 4
BINARY = 5 BINARY = 5
UNDEFINED = 6 UNDEFINED = 6
OID = 7 # x OID = 7
BOOLEAN = 8 # x t BOOLEAN = 8
DATE = 9 # x t DATE = 9
NULL = 10 # x t NULL = 10
REGEX = 11 REGEX = 11
REF = 12 REF = 12
CODE = 13 CODE = 13
SYMBOL = 14 SYMBOL = 14
CODE_W_SCOPE = 15 CODE_W_SCOPE = 15
NUMBER_INT = 16 NUMBER_INT = 16
MAXKEY = 127
def self.serialize_cstr(buf, val) def self.serialize_cstr(buf, val)
buf.put_array(val.to_s.unpack("C*") + [0]) buf.put_array(val.to_s.unpack("C*") + [0])
@ -67,8 +67,10 @@ class BSON
serialize_date_element(@buf, k, v) serialize_date_element(@buf, k, v)
when NULL when NULL
serialize_null_element(@buf, k) serialize_null_element(@buf, k)
when BINARY, UNDEFINED, REF, SYMBOL, CODE_W_SCOPE
raise "unimplemented type #{type}"
else else
raise "Unhandled Type #{type}" raise "unhandled type #{type}"
end end
} }
serialize_eoo_element(@buf) serialize_eoo_element(@buf)