modis 3.1.0 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/CHANGELOG.md +4 -0
- data/lib/modis/persistence.rb +8 -2
- data/lib/modis/version.rb +1 -1
- data/spec/persistence_spec.rb +52 -0
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '09f5ddeac3bce850c66441dc94fe6d485cfd37d8b6d1bad30e9c5318a46f4cbe'
|
4
|
+
data.tar.gz: 499d4e3b84569c92a130c3b8b831bc91e568f993b60b5a075448aa920b807eb1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4372de7a42905bf81d110ecc6fe265dcd17ef1c00938cda35f93984cc543e3d0d85d20f20315c0054ac47f392657dd14cf033b4cb084ab10d3525a57c170f42e
|
7
|
+
data.tar.gz: 5efcd9e86a4dafff8f5e5b53922f9a9a181dfceef4963af27890e7aad6e4b378820f138e974a848c8e03deafd69ffcc3beda64ab500099ea81e7d1f87473afe5
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.6.3
|
data/CHANGELOG.md
CHANGED
data/lib/modis/persistence.rb
CHANGED
@@ -158,16 +158,22 @@ module Modis
|
|
158
158
|
save(validate: false)
|
159
159
|
end
|
160
160
|
|
161
|
-
def
|
161
|
+
def update(attrs)
|
162
162
|
assign_attributes(attrs)
|
163
163
|
save
|
164
164
|
end
|
165
165
|
|
166
|
-
|
166
|
+
alias update_attributes update
|
167
|
+
deprecate update_attributes: 'please, use update instead'
|
168
|
+
|
169
|
+
def update!(attrs)
|
167
170
|
assign_attributes(attrs)
|
168
171
|
save!
|
169
172
|
end
|
170
173
|
|
174
|
+
alias update_attributes! update!
|
175
|
+
deprecate update_attributes!: 'please, use update! instead'
|
176
|
+
|
171
177
|
private
|
172
178
|
|
173
179
|
def coerce_for_persistence(value)
|
data/lib/modis/version.rb
CHANGED
data/spec/persistence_spec.rb
CHANGED
@@ -249,6 +249,33 @@ describe Modis::Persistence do
|
|
249
249
|
end
|
250
250
|
end
|
251
251
|
|
252
|
+
describe 'update!' do
|
253
|
+
it 'updates the given attributes' do
|
254
|
+
model.update!(name: 'Derp', age: 29)
|
255
|
+
model.reload
|
256
|
+
expect(model.name).to eq 'Derp'
|
257
|
+
expect(model.age).to eq 29
|
258
|
+
end
|
259
|
+
|
260
|
+
it 'invokes callbacks' do
|
261
|
+
model.update!(name: 'Derp')
|
262
|
+
expect(model.called_callbacks).to_not be_empty
|
263
|
+
end
|
264
|
+
|
265
|
+
it 'updates all dirty attributes' do
|
266
|
+
model.age = 29
|
267
|
+
model.update!(name: 'Derp')
|
268
|
+
model.reload
|
269
|
+
expect(model.age).to eq 29
|
270
|
+
end
|
271
|
+
|
272
|
+
it 'raises an error if the model is invalid' do
|
273
|
+
expect do
|
274
|
+
model.update!(name: nil).to be false
|
275
|
+
end.to raise_error(Modis::RecordInvalid)
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
252
279
|
describe 'update_attributes!' do
|
253
280
|
it 'updates the given attributes' do
|
254
281
|
model.update_attributes!(name: 'Derp', age: 29)
|
@@ -276,6 +303,31 @@ describe Modis::Persistence do
|
|
276
303
|
end
|
277
304
|
end
|
278
305
|
|
306
|
+
describe 'update' do
|
307
|
+
it 'updates the given attributes' do
|
308
|
+
model.update(name: 'Derp', age: 29)
|
309
|
+
model.reload
|
310
|
+
expect(model.name).to eq('Derp')
|
311
|
+
expect(model.age).to eq(29)
|
312
|
+
end
|
313
|
+
|
314
|
+
it 'invokes callbacks' do
|
315
|
+
model.update(name: 'Derp')
|
316
|
+
expect(model.called_callbacks).to_not be_empty
|
317
|
+
end
|
318
|
+
|
319
|
+
it 'updates all dirty attributes' do
|
320
|
+
model.age = 29
|
321
|
+
model.update(name: 'Derp')
|
322
|
+
model.reload
|
323
|
+
expect(model.age).to eq(29)
|
324
|
+
end
|
325
|
+
|
326
|
+
it 'returns false if the model is invalid' do
|
327
|
+
expect(model.update(name: nil)).to be false
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
279
331
|
describe 'update_attributes' do
|
280
332
|
it 'updates the given attributes' do
|
281
333
|
model.update_attributes(name: 'Derp', age: 29)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: modis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ian Leitch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -259,8 +259,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
259
259
|
- !ruby/object:Gem::Version
|
260
260
|
version: '0'
|
261
261
|
requirements: []
|
262
|
-
|
263
|
-
rubygems_version: 2.7.6
|
262
|
+
rubygems_version: 3.0.4
|
264
263
|
signing_key:
|
265
264
|
specification_version: 4
|
266
265
|
summary: ActiveModel + Redis
|