settingson 1.2.20 → 1.2.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/app/models/concerns/settingson/base.rb +3 -1
- data/lib/settingson/version.rb +1 -1
- data/spec/models/settings_spec.rb +15 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 110ae68451a9445a2d459b139f911a1cecb6619b
|
4
|
+
data.tar.gz: c17ab87809b417eb366117de969c7146213b9f80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9319fecda88cf220da69367a8513f345d265400461b1f9b011755343619d08cf76cd6c65d2bc42fdb33db265a89e34b3eec3bb4996a1746afcdc016418b108fd
|
7
|
+
data.tar.gz: 23258c86ca546023884c41ccd1819b410bd6dbdf41d9eb60d0f71687772aaf6b53457bba9f580cda6b47f35eea887e28282a6b82baa653b7137451847787f0b0
|
data/README.md
CHANGED
@@ -26,8 +26,8 @@ Settings.array = [ 1, 2, 3, 4, 5 ]
|
|
26
26
|
Settings.array # => [1, 2, 3, 4, 5]
|
27
27
|
|
28
28
|
# Array of hashes
|
29
|
-
Settings.
|
30
|
-
Settings.
|
29
|
+
Settings.array_of.hashes = [ { hello: :world}, {'glad' => :to}, {see: 'you'} ]
|
30
|
+
Settings.array_of.hashes # => [{:hello=>:world}, {"glad"=>:to}, {:see=>"you"}]
|
31
31
|
```
|
32
32
|
|
33
33
|
### Using with [Simple Form](https://github.com/plataformatec/simple_form) and [Haml](https://github.com/haml/haml)
|
@@ -68,7 +68,9 @@ module Settingson::Base
|
|
68
68
|
|
69
69
|
@settingson = $1
|
70
70
|
|
71
|
-
if record = find_by(key: @settingson)
|
71
|
+
if record = find_by(key: @settingson) and args.first.nil?
|
72
|
+
record.destroy
|
73
|
+
elsif record
|
72
74
|
record.update(value: args.first.to_yaml)
|
73
75
|
else
|
74
76
|
create(key: @settingson, value: args.first.to_yaml, settingson: @settingson)
|
data/lib/settingson/version.rb
CHANGED
@@ -12,14 +12,27 @@ describe Settings do
|
|
12
12
|
Settings.hello = word
|
13
13
|
expect( Settings.hello ).to eq(word)
|
14
14
|
end
|
15
|
-
it 'returns same value for composit (
|
15
|
+
it 'returns same value for composit (1)' do
|
16
16
|
word = Faker::Lorem.word
|
17
17
|
Settings.hello.hello = word
|
18
18
|
expect( Settings.hello.hello ).to eq(word)
|
19
19
|
end
|
20
|
-
it 'returns same value for composit (2
|
20
|
+
it 'returns same value for composit (2)' do
|
21
21
|
word = Faker::Lorem.word
|
22
22
|
Settings.i.hello = word
|
23
23
|
expect( Settings.i.hello ).to eq(word)
|
24
24
|
end
|
25
|
+
|
26
|
+
it 'destroys record with nil value (1)' do
|
27
|
+
word = Faker::Lorem.word
|
28
|
+
Settings.some = word
|
29
|
+
expect{ Settings.some = nil }.to change{ Settings.count }.by(-1)
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'destroys record with nil value (2)' do
|
33
|
+
word = Faker::Lorem.word
|
34
|
+
Settings.some.hello = word
|
35
|
+
expect{ Settings.some.hello = nil }.to change{ Settings.count }.by(-1)
|
36
|
+
end
|
37
|
+
|
25
38
|
end
|