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 +4 -4
- data/Gemfile.lock +1 -1
- data/dynamini.gemspec +1 -1
- data/lib/dynamini/attributes.rb +10 -1
- data/lib/dynamini/dirty.rb +4 -0
- data/spec/dynamini/dirty_spec.rb +19 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc45db65ca08ec3c36c0485faabc78d4efd5766f
|
4
|
+
data.tar.gz: 29d247ea3e84fe1d2ea19af3afc8e609bbc546a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ef34036274fb4aeba5e220164226ef768d867ba312538de25de2e330d1f3c8d0a52be94a991b60d1f7e50bd4894e22610c9fbcd25b3fdfe42f60cad9f8f7e32
|
7
|
+
data.tar.gz: 07673908634f958be4dc8c21168f15ee75c85c078ed7ee08ca943c93e138a932613de341225e2c01f54bb26073ea74096005b8fcbd84f15c18961e8d7b856998
|
data/Gemfile.lock
CHANGED
data/dynamini.gemspec
CHANGED
data/lib/dynamini/attributes.rb
CHANGED
@@ -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
|
-
|
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)
|
data/lib/dynamini/dirty.rb
CHANGED
data/spec/dynamini/dirty_spec.rb
CHANGED
@@ -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.
|
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:
|
18
|
+
date: 2017-02-22 00:00:00.000000000 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: activemodel
|