settingson 1.2.21 → 1.2.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -0
- data/Rakefile +1 -1
- data/app/models/concerns/settingson/base.rb +9 -9
- data/lib/settingson/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fef8b2be92f46bc95e2ee956d0809cf8faf4abe1
|
4
|
+
data.tar.gz: b73fb6dcc1c767cc307095576fbd8c60f630d2c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 08592f51401ed0e1328d123013bb29c4c4493f31d07d9a5128b2c09d4056155bd49c2de1550823a4aac50761947f0c28db0c4bd1f2c71f4f7df621caa8a27b19
|
7
|
+
data.tar.gz: b57850f82e14020208f02346807c206900ac2275e7ea6ac76a8782f91f4e9a413a7224cf12260ecebb83a2397d65419754c745492fbd39f088b6de763bb56025
|
data/README.md
CHANGED
@@ -29,6 +29,13 @@ Settings.array # => [1, 2, 3, 4, 5]
|
|
29
29
|
Settings.array_of.hashes = [ { hello: :world}, {'glad' => :to}, {see: 'you'} ]
|
30
30
|
Settings.array_of.hashes # => [{:hello=>:world}, {"glad"=>:to}, {:see=>"you"}]
|
31
31
|
```
|
32
|
+
# Boolean
|
33
|
+
Settings.item # => false
|
34
|
+
Settings.item = :hello
|
35
|
+
Settings.item # => true
|
36
|
+
|
37
|
+
# ActiveRecord
|
38
|
+
Settings.item! # => <Settings id: 1, key: "item", value: :hello, created_at: "...", updated_at: "...">
|
32
39
|
|
33
40
|
### Using with [Simple Form](https://github.com/plataformatec/simple_form) and [Haml](https://github.com/haml/haml)
|
34
41
|
in view:
|
data/Rakefile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
|
-
require "rails/dummy/tasks"
|
2
|
+
#require "rails/dummy/tasks"
|
@@ -11,11 +11,11 @@ module Settingson::Base
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def to_s
|
14
|
-
self.new_record? ? '' :
|
14
|
+
self.new_record? ? '' : self.value.to_s
|
15
15
|
end
|
16
16
|
|
17
17
|
def to_i
|
18
|
-
self.new_record? ? 0 :
|
18
|
+
self.new_record? ? 0 : self.value.to_i
|
19
19
|
end
|
20
20
|
|
21
21
|
def method_missing(symbol, *args)
|
@@ -34,12 +34,13 @@ module Settingson::Base
|
|
34
34
|
else
|
35
35
|
self.class.create(key: @settingson, value: args.first.to_yaml)
|
36
36
|
end
|
37
|
-
when /(.+)\?$/ #
|
38
|
-
|
37
|
+
when /(.+)\?$/ # returns boolean
|
39
38
|
@settingson = "#{@settingson}.#{$1}"
|
40
39
|
self.class.find_by(key: @settingson).present?
|
41
|
-
|
42
|
-
|
40
|
+
when /(.+)\!$/ # returns self or nil
|
41
|
+
@settingson = "#{@settingson}.#{$1}"
|
42
|
+
self.class.find_by(key: @settingson)
|
43
|
+
else # returns values or self
|
43
44
|
|
44
45
|
if not defined?(@settingson) or @settingson.blank?
|
45
46
|
@settingson = "#{symbol.to_s}"
|
@@ -48,7 +49,6 @@ module Settingson::Base
|
|
48
49
|
end
|
49
50
|
|
50
51
|
if record = self.class.find_by(key: @settingson)
|
51
|
-
# YAML.load(record.value)
|
52
52
|
record.value
|
53
53
|
else
|
54
54
|
self
|
@@ -77,9 +77,9 @@ module Settingson::Base
|
|
77
77
|
end
|
78
78
|
|
79
79
|
when /(.+)\?$/ #
|
80
|
-
|
81
80
|
find_by(key: $1).present?
|
82
|
-
|
81
|
+
when /(.+)\!$/ # returns self or nil
|
82
|
+
find_by(key: $1)
|
83
83
|
else # getter
|
84
84
|
|
85
85
|
if record = find_by(key: symbol.to_s)
|
data/lib/settingson/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: settingson
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.22
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- dan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -213,7 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
213
213
|
version: '0'
|
214
214
|
requirements: []
|
215
215
|
rubyforge_project:
|
216
|
-
rubygems_version: 2.
|
216
|
+
rubygems_version: 2.4.3
|
217
217
|
signing_key:
|
218
218
|
specification_version: 4
|
219
219
|
summary: Settings management for Ruby on Rails 4 applications (ActiveRecord)
|