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: d9f474258f3d2248355c75bfaaed2439a6f17d01
4
- data.tar.gz: a7f227175a6583d765931a9feda03e8ede33b4b0
3
+ metadata.gz: fea522cd38d362c1f89a69c7fd9492b72a4d9057
4
+ data.tar.gz: 77cd21ab722c5262b9150af01ee94bdd3c6e9539
5
5
  SHA512:
6
- metadata.gz: f2f2191bb5cec0d4e138b3adeafdd6a779bd032f31c2d93f8862484676afd5683f6fdb7bf230ebe3f6f9a0e9843f6d0b58f1278917c5db5488f684ff6664a978
7
- data.tar.gz: 4f74a8624f48916154ffa549d5e0320c3679db8534280c4593669bc4a2f000d32bdd3947dd2e673b75fae4d8708102b8c3c5492a9c76cece3ea6a9026c177cb6
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.to_sym)
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.to_sym)
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
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module TypedStore
3
- VERSION = '1.1.0'
3
+ VERSION = '1.1.1'
4
4
  end
5
5
  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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-typedstore
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean Boussier