@@ -43,21 +43,23 @@ class << self
43
43
# @example
44
44
# Mongoid::FieldTypes.get(:point)
45
45
#
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 )
49
51
end
50
52
51
53
# Defines a field type mapping, for later use in field :type option.
52
54
#
53
55
# @example
54
56
# Mongoid::FieldTypes.define(:point, Point)
55
57
#
56
- # @param [ Symbol ] symbol the symbol identifier of the defined type
58
+ # @param [ Symbol ] type the symbol identifier of the defined type
57
59
# @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
61
63
end
62
64
63
65
delegate :delete , to : :mapping
@@ -74,6 +76,8 @@ def mapping
74
76
# Handles fallback for case where mapping does not contain the
75
77
# requested type.
76
78
#
79
+ # @param [ Symbol | String | Class | nil ] type the identifier of the defined
80
+ # type, or a class, or nil.
77
81
# @return [ Class | nil ] The class to use as a fallback, or nil.
78
82
def handle_unmapped_type ( type )
79
83
return Object if type . nil?
0 commit comments