Method: BSON::Registry#get

Defined in:
lib/bson/registry.rb

#get(byte, field = nil) ⇒ Class

Get the class for the single byte identifier for the type in the BSON specification.

Examples:

Get the type for the byte.

BSON::Registry.get("\x01")

Returns:

  • (Class)

    The corresponding Ruby class for the type.

See Also:

Since:

  • 2.0.0



44
45
46
47
48
49
50
# File 'lib/bson/registry.rb', line 44

def get(byte, field = nil)
  if type = MAPPINGS[byte] || (byte.is_a?(String) && type = MAPPINGS[byte.ord])
    type
  else
    handle_unsupported_type!(byte, field)
  end
end