settingson 0.1.1 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +26 -0
- data/lib/settingson/store.rb +6 -2
- data/lib/settingson/version.rb +1 -1
- 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: b5ec5ec1073690c77961b2e0e0fb55a5143b4fc9
|
4
|
+
data.tar.gz: d868fc55ac06f6ce9989aef02e199eecf12d7704
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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:
|
data/lib/settingson/store.rb
CHANGED
@@ -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
|
-
|
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
|
data/lib/settingson/version.rb
CHANGED