dynamini 2.12.2 → 2.12.3

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
- SHA256:
3
- metadata.gz: 7c5532b785f0dddd894eb863f17905aab853a124fb3aeb6b046e67b3f0574b2a
4
- data.tar.gz: 6b897e7501ec92aab731f94dbf93ee830ed4e0b615103e4b268c38f2796fbb05
2
+ SHA1:
3
+ metadata.gz: 64d5c75ec0d58bf5f50ed320dfbbe10a255d051d
4
+ data.tar.gz: 3da5fdfd2a11ea2a16be31a704667847defa025a
5
5
  SHA512:
6
- metadata.gz: 11dd2f65ba75d324367f9493fa8a0f2bdfca46526d2647cc738e3c7661303ada53e1aac4409770b393c837a90a892988296e20645374fff4d9d87ad513ac701c
7
- data.tar.gz: fdb2715ba459b388db428af4b46a2cb11281fd6efd8a3471f3e9ce13c7c0893ed5424a6b422c20797eec8c57ba01fbf06284edd634abd311b587db4e78b05ab8
6
+ metadata.gz: 92e8327fdd80e05f6cf364da201f585cd4b06744cc9b92ddc987d3dc55d5e234104e146d40e730e3954291a6b197043db1547b4c2bfe7ea5c191967e468bf6a5
7
+ data.tar.gz: f2ab1310bea3cc6ee8da4b0bdee4824919bf8593d8115a1309a302c16327d7c01d1843328b0b3f939a45fc79d4f29c8644f1ccbdc5313144e87d61d2f293846e
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dynamini (2.12.1)
4
+ dynamini (2.12.2)
5
5
  activemodel (>= 3, < 5.0)
6
6
  aws-sdk (~> 2)
7
7
 
@@ -16,13 +16,13 @@ GEM
16
16
  minitest (~> 5.1)
17
17
  thread_safe (~> 0.3, >= 0.3.4)
18
18
  tzinfo (~> 1.1)
19
- aws-sdk (2.11.4)
20
- aws-sdk-resources (= 2.11.4)
21
- aws-sdk-core (2.11.4)
19
+ aws-sdk (2.10.131)
20
+ aws-sdk-resources (= 2.10.131)
21
+ aws-sdk-core (2.10.131)
22
22
  aws-sigv4 (~> 1.0)
23
23
  jmespath (~> 1.0)
24
- aws-sdk-resources (2.11.4)
25
- aws-sdk-core (= 2.11.4)
24
+ aws-sdk-resources (2.10.131)
25
+ aws-sdk-core (= 2.10.131)
26
26
  aws-sigv4 (1.0.2)
27
27
  builder (3.2.3)
28
28
  coderay (1.1.0)
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'dynamini'
3
- s.version = '2.12.2'
3
+ s.version = '2.12.3'
4
4
  s.summary = 'DynamoDB interface'
5
5
  s.description = 'Lightweight DynamoDB interface gem designed as
6
6
  a drop-in replacement for ActiveRecord.
@@ -110,16 +110,21 @@ module Dynamini
110
110
  new_value = self.class.attribute_callback(TypeHandler::SETTER_PROCS, handle, new_value, change)
111
111
  end
112
112
  @attributes[attribute] = new_value
113
- if change && new_value != old_value
114
- @original_values ||= {}
115
- @original_values[attribute] = old_value unless @original_values.keys.include?(attribute)
116
- if new_value == @original_values[attribute]
117
- clear_change(attribute)
118
- else
119
- record_change(attribute, old_value, new_value, options[:action])
120
- end
113
+ set_original_value(attribute, old_value) if change
114
+ process_change(attribute, new_value, old_value, options) if change == true && new_value != old_value
115
+ end
116
+
117
+ def process_change(attribute, new_value, old_value, options)
118
+ if new_value == @original_values[attribute]
119
+ clear_change(attribute)
120
+ else
121
+ record_change(attribute, old_value, new_value, options[:action])
121
122
  end
123
+ end
122
124
 
125
+ def set_original_value(attribute, old_value)
126
+ @original_values ||= {}
127
+ @original_values[attribute] = old_value unless @original_values.keys.include?(attribute)
123
128
  end
124
129
 
125
130
  def read_attribute(name)
@@ -130,5 +135,7 @@ module Dynamini
130
135
  end
131
136
  value
132
137
  end
138
+
139
+
133
140
  end
134
141
  end
@@ -21,6 +21,10 @@ module Dynamini
21
21
  end
22
22
  end
23
23
 
24
+ def assign_transient_attribute(key, value)
25
+ write_attribute(key, value, change: :transient)
26
+ end
27
+
24
28
  private
25
29
 
26
30
  def record_change(attribute, old_value, new_value, action)
@@ -195,4 +195,32 @@ describe Dynamini::Dirty do
195
195
  expect(model.changed).to eq(['price', 'name'])
196
196
  end
197
197
  end
198
+
199
+ describe '#assign_transient_attribute' do
200
+ it 'should update the value without marking a change' do
201
+ model.assign_transient_attribute(:transient, 'hello')
202
+ expect(model.transient).to eq('hello')
203
+ expect(model.changes).to eq({})
204
+ end
205
+
206
+ context 'when going back to the old value' do
207
+ context 'using assign transient attribute again' do
208
+ it 'should reset the value without marking a change' do
209
+ old_price = model.price
210
+ model.assign_transient_attribute(:price, old_price + 1)
211
+ model.assign_transient_attribute(:price, old_price)
212
+ expect(model.changes).to eq({})
213
+ end
214
+ end
215
+
216
+ context 'using a regular writer' do
217
+ it 'should reset the value without marking a change' do
218
+ old_price = model.price
219
+ model.assign_transient_attribute(:price, old_price + 1)
220
+ model.price = old_price
221
+ expect(model.changes).to eq({})
222
+ end
223
+ end
224
+ end
225
+ end
198
226
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamini
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.12.2
4
+ version: 2.12.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Ward
@@ -15,7 +15,7 @@ authors:
15
15
  autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
- date: 2018-07-04 00:00:00.000000000 Z
18
+ date: 2018-07-25 00:00:00.000000000 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: activemodel
@@ -186,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
186
  version: '0'
187
187
  requirements: []
188
188
  rubyforge_project:
189
- rubygems_version: 2.7.3
189
+ rubygems_version: 2.5.1
190
190
  signing_key:
191
191
  specification_version: 4
192
192
  summary: DynamoDB interface