dynamini 2.7.6 → 2.7.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1db2d21499fb1ae5bac1a91248f14ccc8c0adbda
4
- data.tar.gz: 6b9c2f937622394c1c1c0ec41da703dd973beadd
3
+ metadata.gz: fc45db65ca08ec3c36c0485faabc78d4efd5766f
4
+ data.tar.gz: 29d247ea3e84fe1d2ea19af3afc8e609bbc546a9
5
5
  SHA512:
6
- metadata.gz: c7a17edab0369bf6a35504b47b71b573f852ecd2f670845c2c13c8b5235c58bdb25f90aa907d93aab3e416b0e7039d527895fd802161f613ace8837c35f4fbe5
7
- data.tar.gz: b4e085cd274edb7b9071cc5a7bedcb49498dfd9df0006bd302d80eaebaa2cbb3bb953ecbeb0886b98d8a2208e36b4cd3f5aba38cb642c8c46c34f887067b9a00
6
+ metadata.gz: 5ef34036274fb4aeba5e220164226ef768d867ba312538de25de2e330d1f3c8d0a52be94a991b60d1f7e50bd4894e22610c9fbcd25b3fdfe42f60cad9f8f7e32
7
+ data.tar.gz: 07673908634f958be4dc8c21168f15ee75c85c078ed7ee08ca943c93e138a932613de341225e2c01f54bb26073ea74096005b8fcbd84f15c18961e8d7b856998
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dynamini (2.7.5)
4
+ dynamini (2.7.6)
5
5
  activemodel (>= 3, < 5.0)
6
6
  aws-sdk (~> 2)
7
7
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'dynamini'
3
- s.version = '2.7.6'
3
+ s.version = '2.7.7'
4
4
  s.summary = 'DynamoDB interface'
5
5
  s.description = 'Lightweight DynamoDB interface gem designed as
6
6
  a drop-in replacement for ActiveRecord.
@@ -98,7 +98,16 @@ module Dynamini
98
98
  new_value = self.class.attribute_callback(TypeHandler::SETTER_PROCS, handle, new_value, change)
99
99
  end
100
100
  @attributes[attribute] = new_value
101
- record_change(attribute, old_value, new_value, options[:action]) if change && new_value != old_value
101
+ if change && new_value != old_value
102
+ @original_values ||= {}
103
+ @original_values[attribute] = old_value unless @original_values.keys.include?(attribute)
104
+ if new_value == @original_values[attribute]
105
+ clear_change(attribute)
106
+ else
107
+ record_change(attribute, old_value, new_value, options[:action])
108
+ end
109
+ end
110
+
102
111
  end
103
112
 
104
113
  def read_attribute(name)
@@ -28,6 +28,10 @@ module Dynamini
28
28
  @changes[attribute] = [old_value, new_value, action]
29
29
  end
30
30
 
31
+ def clear_change(attribute)
32
+ @changes.delete(attribute)
33
+ end
34
+
31
35
  def clear_changes
32
36
  @changes = Hash.new { |hash, key| hash[key] = Array.new(2) }
33
37
  end
@@ -140,6 +140,25 @@ describe Dynamini::Dirty do
140
140
  end
141
141
  end
142
142
 
143
+ context 'attribute changed then changed back' do
144
+ context 'when old value was present' do
145
+ it 'should not count as a change' do
146
+ old_price = model.price
147
+ model.price = nil
148
+ model.price = old_price
149
+ expect(model.changes).to eq({})
150
+ end
151
+ end
152
+
153
+ context 'when old value was nil' do
154
+ it 'should not count as a change' do
155
+ model.new_attr = 'hello'
156
+ model.new_attr = nil
157
+ expect(model.changes).to eq({})
158
+ end
159
+ end
160
+ end
161
+
143
162
  context 'attribute changed with ADD action' do
144
163
 
145
164
  class AddModel < Dynamini::Base
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.7.6
4
+ version: 2.7.7
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: 2016-12-07 00:00:00.000000000 Z
18
+ date: 2017-02-22 00:00:00.000000000 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: activemodel