activerecord-typedstore 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fea522cd38d362c1f89a69c7fd9492b72a4d9057
|
4
|
+
data.tar.gz: 77cd21ab722c5262b9150af01ee94bdd3c6e9539
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42332f9a8e566e555e4bee6696ffa7b803f886e0d6a37f589216b8665d0bf94c7726dab22f2878179f3bbc9be13174f2cfcbb07d33d8b08baea3dfd14b35165a
|
7
|
+
data.tar.gz: fcbb9def1916703be1b236f8674795c6779941364199fa4e9997e34adc250f0fa1a1f5acb767b24fef951f237ec88c68a57d1fec7dbf985f6d3d5e182d8f19b9
|
@@ -57,12 +57,12 @@ module ActiveRecord::TypedStore
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def clear_attribute_change(attr_name)
|
60
|
-
return if self.class.store_accessors.include?(attr_name
|
60
|
+
return if self.class.store_accessors.include?(normalize_attribute(attr_name))
|
61
61
|
super
|
62
62
|
end
|
63
63
|
|
64
64
|
def read_attribute(attr_name)
|
65
|
-
if self.class.store_accessors.include?(attr_name
|
65
|
+
if self.class.store_accessors.include?(normalize_attribute(attr_name))
|
66
66
|
return public_send(attr_name)
|
67
67
|
end
|
68
68
|
super
|
@@ -96,5 +96,14 @@ module ActiveRecord::TypedStore
|
|
96
96
|
super
|
97
97
|
end
|
98
98
|
end
|
99
|
+
|
100
|
+
def normalize_attribute(attr)
|
101
|
+
case attr
|
102
|
+
when Symbol
|
103
|
+
attr
|
104
|
+
else
|
105
|
+
attr.to_s.to_sym
|
106
|
+
end
|
107
|
+
end
|
99
108
|
end
|
100
109
|
end
|
@@ -145,6 +145,14 @@ shared_examples 'any model' do
|
|
145
145
|
model.name = 'foo'
|
146
146
|
expect(model.read_attribute(:name)).to be == 'foo'
|
147
147
|
end
|
148
|
+
|
149
|
+
it 'is accessible through #read_attribute when attribute is nil' do
|
150
|
+
expect(model.read_attribute(nil)).to be_nil
|
151
|
+
end
|
152
|
+
|
153
|
+
it 'allows #increment! when attribute is nil' do
|
154
|
+
expect { model.increment!(nil) }.to raise_error(ActiveModel::MissingAttributeError)
|
155
|
+
end
|
148
156
|
end
|
149
157
|
|
150
158
|
describe 'string attribute' do
|