Provides constant values for each to the BSON types and mappings from raw bytes back to these types.
@see bsonspec.org/#/specification
@since 2.0.0
Get the class for the single byte identifier for the type in the BSON specification.
@example Get the type for the byte.
BSON::Registry.get("\x01")
@return [ Class ] The corresponding Ruby class for the type.
@see bsonspec.org/#/specification
@since 2.0.0
# File lib/bson/registry.rb, line 42 def get(byte) MAPPINGS.fetch(byte) end
Register the Ruby type for the corresponding single byte.
@example Register the type.
BSON::Registry.register("\x01", Float)
@param [ String ] byte The single byte. @param [ Class ] The class the byte maps to.
@return [ Class ] The class.
@since 2.0.0
# File lib/bson/registry.rb, line 57 def register(byte, type) MAPPINGS.store(byte, type) define_type_reader(type) end
Generated with the Darkfish Rdoc Generator 2.