File tree Expand file tree Collapse file tree 4 files changed +14
-14
lines changed Expand file tree Collapse file tree 4 files changed +14
-14
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ module Fields
16
16
Boolean = Mongoid ::Boolean
17
17
18
18
# @deprecated
19
- TYPE_MAPPINGS = ::Mongoid ::Fields ::FieldTypes ::DEFAULT_MAPPING
19
+ TYPE_MAPPINGS = ::Mongoid ::Fields ::FieldTypes ::DEFAULT_ALIASES
20
20
21
21
# Constant for all names of the _id field in a document.
22
22
#
Original file line number Diff line number Diff line change @@ -9,10 +9,10 @@ module Fields
9
9
# @api private
10
10
module FieldTypes
11
11
12
- # The default mapping of field type symbol to class .
12
+ # The default mapping of field type symbol/string aliases to classes .
13
13
#
14
14
# @api private
15
- DEFAULT_MAPPING = {
15
+ DEFAULT_ALIASES = {
16
16
array : Array ,
17
17
big_decimal : BigDecimal ,
18
18
binary : BSON ::Binary ,
@@ -67,7 +67,7 @@ def define(type, klass)
67
67
#
68
68
# @return [ ActiveSupport::HashWithIndifferentAccess<Symbol, Class> ] The memoized field mapping.
69
69
def mapping
70
- @mapping ||= DEFAULT_MAPPING . dup
70
+ @mapping ||= DEFAULT_ALIASES . dup
71
71
end
72
72
73
73
private
Original file line number Diff line number Diff line change 5
5
describe Mongoid ::Fields ::FieldTypes do
6
6
7
7
around do |example |
8
- described_class . instance_variable_set ( :@mapping , described_class ::DEFAULT_MAPPING . dup )
8
+ described_class . instance_variable_set ( :@mapping , described_class ::DEFAULT_ALIASES . dup )
9
9
example . run
10
- described_class . instance_variable_set ( :@mapping , described_class ::DEFAULT_MAPPING . dup )
10
+ described_class . instance_variable_set ( :@mapping , described_class ::DEFAULT_ALIASES . dup )
11
11
end
12
12
13
13
describe '.get' do
103
103
expect ( described_class . get ( :integer ) ) . to eq String
104
104
end
105
105
106
- it 'does not alter the DEFAULT_MAPPING constant' do
106
+ it 'does not alter the DEFAULT_ALIASES constant' do
107
107
described_class . define ( :integer , String )
108
- expect ( described_class ::DEFAULT_MAPPING [ :integer ] ) . to eq Integer
108
+ expect ( described_class ::DEFAULT_ALIASES [ :integer ] ) . to eq Integer
109
109
end
110
110
end
111
111
123
123
expect ( described_class . get ( :integer ) ) . to eq nil
124
124
end
125
125
126
- it 'does not alter the DEFAULT_MAPPING constant' do
126
+ it 'does not alter the DEFAULT_ALIASES constant' do
127
127
described_class . delete ( :integer )
128
- expect ( described_class ::DEFAULT_MAPPING [ :integer ] ) . to eq Integer
128
+ expect ( described_class ::DEFAULT_ALIASES [ :integer ] ) . to eq Integer
129
129
end
130
130
end
131
131
132
132
describe '.mapping' do
133
133
134
134
it 'returns the default mapping by default' do
135
- expect ( described_class . mapping ) . to eq described_class ::DEFAULT_MAPPING
135
+ expect ( described_class . mapping ) . to eq described_class ::DEFAULT_ALIASES
136
136
end
137
137
138
138
it 'can add a type' do
Original file line number Diff line number Diff line change @@ -1786,9 +1786,9 @@ class DiscriminatorChild2 < DiscriminatorParent
1786
1786
context '.type method' do
1787
1787
around do |example |
1788
1788
klass = Mongoid ::Fields ::FieldTypes
1789
- klass . instance_variable_set ( :@mapping , klass ::DEFAULT_MAPPING . dup )
1789
+ klass . instance_variable_set ( :@mapping , klass ::DEFAULT_ALIASES . dup )
1790
1790
example . run
1791
- klass . instance_variable_set ( :@mapping , klass ::DEFAULT_MAPPING . dup )
1791
+ klass . instance_variable_set ( :@mapping , klass ::DEFAULT_ALIASES . dup )
1792
1792
end
1793
1793
1794
1794
it 'can define a custom type' do
@@ -1838,7 +1838,7 @@ def self.model_name
1838
1838
1839
1839
describe '::TYPE_MAPPINGS' do
1840
1840
it 'returns the default mapping' do
1841
- expect ( described_class ::TYPE_MAPPINGS ) . to eq ::Mongoid ::Fields ::FieldTypes ::DEFAULT_MAPPING
1841
+ expect ( described_class ::TYPE_MAPPINGS ) . to eq ::Mongoid ::Fields ::FieldTypes ::DEFAULT_ALIASES
1842
1842
end
1843
1843
end
1844
1844
end
You can’t perform that action at this time.
0 commit comments