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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 114d6e67d5c7fb37b65323e01ad0f1efcf3e8d84
4
- data.tar.gz: 88cc05ff61a07d96d6a455485c1c4a0f94ad551b
3
+ metadata.gz: 110ae68451a9445a2d459b139f911a1cecb6619b
4
+ data.tar.gz: c17ab87809b417eb366117de969c7146213b9f80
5
5
  SHA512:
6
- metadata.gz: 79e0872ea387384ae42b08c7d53b7860b90fc80d534e0a2745f293dc36dcfb6d92400f1242fba3cc9a9de4e402cbb0eebdb8b53455cec554bf15c5a02ed987bd
7
- data.tar.gz: 71fe6bd7c4d908e53e6ec5412c985bf24c48879927341a510b30f5170e29c6d5d62fcda710c0b01a467fb6c16635ff840d3f6d6fd36bb5bf13762ecef3edfd47
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.array.of.hashes = [ { hello: :world}, {'glad' => :to}, {see: 'you'} ]
30
- Settings.array.of.hashes # => [{:hello=>:world}, {"glad"=>:to}, {:see=>"you"}]
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)
@@ -1,3 +1,3 @@
1
1
  module Settingson
2
- VERSION = "1.2.20"
2
+ VERSION = "1.2.21"
3
3
  end
@@ -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 (2.1)' do
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.2)' do
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: settingson
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.20
4
+ version: 1.2.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - dan