Registry — Documentation by YARD 0.9.37 (original) (raw)

Module: Mongo::Protocol::Registry

Extended by:

Registry

Included in:

Registry

Defined in:

lib/mongo/protocol/registry.rb

Overview

Provides a registry for looking up a message class based on op code.

Constant Summarycollapse

MAPPINGS =

A Mapping of all the op codes to their corresponding Ruby classes.

{}

Instance Method Summarycollapse

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, message = 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