Module: Mongo::Protocol::Registry
Overview
Provides a registry for looking up a message class based on op code.
Constant Summary collapse
- MAPPINGS =
A Mapping of all the op codes to their corresponding Ruby classes.
{}
Instance Method Summary collapse
-
#get(op_code, message = nil) ⇒ Class
Get the class for the given op code and raise an error if it’s not found.
-
#register(op_code, type) ⇒ Class
Register the Ruby type for the corresponding op code.
Instance Method Details
#get(op_code, message = nil) ⇒ Class
Get the class for the given op code and raise an error if it’s not found.
41 42 43 44 45 46 47 |
# File 'lib/mongo/protocol/registry.rb', line 41 def get(op_code, = nil) if type = MAPPINGS[op_code] type else handle_unsupported_op_code!(op_code) end end |
#register(op_code, type) ⇒ Class
Register the Ruby type for the corresponding op code.
60 61 62 63 |
# File 'lib/mongo/protocol/registry.rb', line 60 def register(op_code, type) MAPPINGS.store(op_code, type) define_type_reader(type) end |