settingson 0.1.1 → 0.1.6

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: c45e0fe97f344f3bb38ee9632a70f2ae72ea2c79
4
- data.tar.gz: b0ff834e5623d24da90c18b6eae0b01fc9ef3f56
3
+ metadata.gz: b5ec5ec1073690c77961b2e0e0fb55a5143b4fc9
4
+ data.tar.gz: d868fc55ac06f6ce9989aef02e199eecf12d7704
5
5
  SHA512:
6
- metadata.gz: 812fba267cf8f56b5ed924a64f649808860a05c194e7ba6d1d3b43ca9b460cc0f3a5b7b878c05c295d460521f9dff15b319aea9260395ee1fc6190a84299e3ca
7
- data.tar.gz: 2adb0f77056e1e2fb0ba4b8a97fdf4817f2e7d2d2cf0e600f4925ccb7fedf3fecf13c6128ad0b4b410a45c596a586cc1d55c002eee7c32f03a17331f0a331a8e
6
+ metadata.gz: 86b8126194e7d29399feaef089f39754be43554090fc442097a4c71b5af06fd26b0df0ff606869b76cb75ecc09747fabad3a70ccddd4adad6daf98d15b7fc7d2
7
+ data.tar.gz: 538cf7e95a9089123bbc6451221eb2c02789d25258c6c26acb493b3194bd9e6a1fd3c07dc25bd76ed0590aa238f0fb11b2f90015e1a72f0f4215812d3b2f946e
data/README.md CHANGED
@@ -4,6 +4,32 @@
4
4
 
5
5
  Settings management for Ruby on Rails 4 applications (ActiveRecord)
6
6
 
7
+ ```ruby
8
+ Settings.server.host = '127.0.0.1'
9
+ Settings.server.port = '8888'
10
+
11
+ Settings.server.host # => '127.0.0.1'
12
+ Settings.server.port # => '8888'
13
+
14
+ Settings.server.smtp.host = '127.0.0.1'
15
+ Settings.server.smtp.port = 25
16
+
17
+ Settings.server.smtp.host # => "127.0.0.1"
18
+ Settings.server.smtp.port # => 25
19
+
20
+ # With hash
21
+ Settings.rules = { '1st RULE' => 'You do not talk about FIGHT CLUB.' }
22
+ Settings.rules['1st RULE'] # => "You do not talk about FIGHT CLUB."
23
+
24
+ # With array
25
+ Settings.array = [ 1, 2, 3, 4, 5 ]
26
+ Settings.array # => [1, 2, 3, 4, 5]
27
+
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"}]
31
+ ```
32
+
7
33
  ## Installation
8
34
 
9
35
  Add this line to your application's Gemfile:
@@ -29,10 +29,14 @@ class Settingson::Store
29
29
  when /(.+)=/
30
30
  @name = @name.nil? ? $1 : @name + ".#{$1}"
31
31
  if record = @klass.find_by(name: @name)
32
- record.update(value: value.to_yaml)
32
+ if value.nil?
33
+ record.destroy
34
+ else
35
+ record.update(value: value.to_yaml)
36
+ end
33
37
  value
34
38
  else
35
- @klass.create(name: @name, value: value.to_yaml)
39
+ @klass.create(name: @name, value: value.to_yaml) unless value.nil?
36
40
  value
37
41
  end
38
42
  else
@@ -1,3 +1,3 @@
1
1
  module Settingson
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.6"
3
3
  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: 0.1.1
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - dan