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 +5 -5
- data/Gemfile.lock +6 -6
- data/dynamini.gemspec +1 -1
- data/lib/dynamini/attributes.rb +15 -8
- data/lib/dynamini/dirty.rb +4 -0
- data/spec/dynamini/dirty_spec.rb +28 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 64d5c75ec0d58bf5f50ed320dfbbe10a255d051d
|
4
|
+
data.tar.gz: 3da5fdfd2a11ea2a16be31a704667847defa025a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92e8327fdd80e05f6cf364da201f585cd4b06744cc9b92ddc987d3dc55d5e234104e146d40e730e3954291a6b197043db1547b4c2bfe7ea5c191967e468bf6a5
|
7
|
+
data.tar.gz: f2ab1310bea3cc6ee8da4b0bdee4824919bf8593d8115a1309a302c16327d7c01d1843328b0b3f939a45fc79d4f29c8644f1ccbdc5313144e87d61d2f293846e
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
dynamini (2.12.
|
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.
|
20
|
-
aws-sdk-resources (= 2.
|
21
|
-
aws-sdk-core (2.
|
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.
|
25
|
-
aws-sdk-core (= 2.
|
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)
|
data/dynamini.gemspec
CHANGED
data/lib/dynamini/attributes.rb
CHANGED
@@ -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
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
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
|
data/lib/dynamini/dirty.rb
CHANGED
data/spec/dynamini/dirty_spec.rb
CHANGED
@@ -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.
|
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-
|
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.
|
189
|
+
rubygems_version: 2.5.1
|
190
190
|
signing_key:
|
191
191
|
specification_version: 4
|
192
192
|
summary: DynamoDB interface
|