Skip to content

Commit 0049e29

Browse files
committed
Fix bug
1 parent 4717986 commit 0049e29

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/mongoid/fields/field_types.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,12 @@ module FieldTypes
3636
}.with_indifferent_access.freeze
3737

3838
def get(value)
39+
value = value.to_sym if value.is_a?(String)
3940
mapping[value] || handle_unmapped_type(value)
4041
end
4142

4243
def define(symbol, klass)
43-
mapping[symbol] = klass
44+
mapping[symbol.to_sym] = klass
4445
end
4546

4647
delegate :delete, to: :mapping
@@ -53,7 +54,6 @@ def handle_unmapped_type(type)
5354
return Object if type.nil?
5455

5556
if type.is_a?(Module)
56-
symbol = type.name.demodulize.underscore
5757
warn_class_type(type.name)
5858
return Mongoid::Boolean if type.to_s == 'Boolean'
5959
return type
@@ -64,6 +64,7 @@ def handle_unmapped_type(type)
6464

6565
def warn_class_type(type)
6666
return if warned_class_types.include?(type)
67+
symbol = type.demodulize.underscore
6768
Mongoid.logger.warn(
6869
"Using a Class (#{type}) in the field :type option is deprecated " +
6970
"and will be removed in a future major Mongoid version. " +

0 commit comments

Comments
 (0)