@@ -43,21 +43,23 @@ class << self
4343 # @example
4444 # Mongoid::FieldTypes.get(:point)
4545 #
46- # @param [ Symbol | String ] value the identifier of the defined type
47- def get ( value )
48- mapping [ value ] || handle_unmapped_type ( value )
46+ # @param [ Symbol | String | Class | nil ] type the identifier of the defined
47+ # type, or a class to pass-through, or nil.
48+ # @return [ Class | nil ] The mapped type class, or nil.
49+ def get ( type )
50+ mapping [ type ] || handle_unmapped_type ( type )
4951 end
5052
5153 # Defines a field type mapping, for later use in field :type option.
5254 #
5355 # @example
5456 # Mongoid::FieldTypes.define(:point, Point)
5557 #
56- # @param [ Symbol ] symbol the symbol identifier of the defined type
58+ # @param [ Symbol ] type the symbol identifier of the defined type
5759 # @param [ Class ] klass the class of the defined type, which must
58- # include mongoize and related methods.
59- def define ( symbol , klass )
60- mapping [ symbol . to_sym ] = klass
60+ # include mongoize, demongoize, and evolve methods.
61+ def define ( type , klass )
62+ mapping [ type ] = klass
6163 end
6264
6365 delegate :delete , to : :mapping
@@ -74,6 +76,8 @@ def mapping
7476 # Handles fallback for case where mapping does not contain the
7577 # requested type.
7678 #
79+ # @param [ Symbol | String | Class | nil ] type the identifier of the defined
80+ # type, or a class, or nil.
7781 # @return [ Class | nil ] The class to use as a fallback, or nil.
7882 def handle_unmapped_type ( type )
7983 return Object if type . nil?
0 commit comments