smart_settings 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -1
- data/lib/smart_settings/persistence.rb +9 -2
- data/lib/smart_settings/version.rb +1 -1
- metadata +3 -4
- data/Gemfile.lock +0 -44
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13b9e02e948f0cd9036e96d8a3746eb2bdb3328c
|
4
|
+
data.tar.gz: f877f01cca18f28ba110b6e3ce4a6a7ffe970ff1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd1215594e9814a60b5b139f1ccf47761935c866fed1aea7d8717bf91b074b3b56ba616e6fa1b970fc5632e73ceef62b3f445662a52a69517b39535f43bafed5
|
7
|
+
data.tar.gz: 6d64ba1b64cdfe11b73e7ec988a9beb2afc958e101cf4644d46c107ca4b8917e4d5c4db45b5c5495fc0bc3239c56bf22b0c3b14e7c55775397d7b7d7bf57a71a
|
data/README.md
CHANGED
@@ -50,9 +50,12 @@ end
|
|
50
50
|
Then you can use the `Setting` model or the `EmailSettings` class to get and set attributes:
|
51
51
|
|
52
52
|
```ruby
|
53
|
-
# Get email settings using the Setting model
|
53
|
+
# Get email settings using the Setting model querying
|
54
54
|
email = Setting.find(:email)
|
55
55
|
|
56
|
+
# Get email settings using the Setting model methods
|
57
|
+
email = Setting.email
|
58
|
+
|
56
59
|
# Get email settings using EmailSettings class
|
57
60
|
email = EmailSettings
|
58
61
|
|
@@ -6,7 +6,7 @@ module SmartSettings
|
|
6
6
|
after_initialize do
|
7
7
|
self.var = var
|
8
8
|
|
9
|
-
settings.each do |setting|
|
9
|
+
settings.try(:each) do |setting|
|
10
10
|
svar, value = [setting.var, setting.value]
|
11
11
|
send(:"#{svar}=", cast_setting_value(svar, value))
|
12
12
|
end
|
@@ -30,7 +30,10 @@ module SmartSettings
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def settings
|
33
|
-
|
33
|
+
if settings_table_exists?
|
34
|
+
valid = self.attribute_names.reject { |i| i == 'var' }
|
35
|
+
Setting.where(settable_type: self.class.name, settable_id: id, var: valid)
|
36
|
+
end
|
34
37
|
end
|
35
38
|
|
36
39
|
private
|
@@ -55,5 +58,9 @@ module SmartSettings
|
|
55
58
|
create_setting(var, value)
|
56
59
|
end
|
57
60
|
end
|
61
|
+
|
62
|
+
def settings_table_exists?
|
63
|
+
ActiveRecord::Base.connection.table_exists? Setting.table_name
|
64
|
+
end
|
58
65
|
end
|
59
66
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_settings
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonian Guveli
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -90,7 +90,6 @@ extra_rdoc_files: []
|
|
90
90
|
files:
|
91
91
|
- CODE_OF_CONDUCT.md
|
92
92
|
- Gemfile
|
93
|
-
- Gemfile.lock
|
94
93
|
- LICENSE.txt
|
95
94
|
- README.md
|
96
95
|
- Rakefile
|
@@ -127,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
126
|
version: '0'
|
128
127
|
requirements: []
|
129
128
|
rubyforge_project:
|
130
|
-
rubygems_version: 2.6.
|
129
|
+
rubygems_version: 2.6.14
|
131
130
|
signing_key:
|
132
131
|
specification_version: 4
|
133
132
|
summary: Persist application or record settings on ActiveRecord
|
data/Gemfile.lock
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
smart_settings (0.1.0)
|
5
|
-
activerecord (~> 5.0)
|
6
|
-
tableless (~> 0.1)
|
7
|
-
|
8
|
-
GEM
|
9
|
-
remote: https://rubygems.org/
|
10
|
-
specs:
|
11
|
-
activemodel (5.1.4)
|
12
|
-
activesupport (= 5.1.4)
|
13
|
-
activerecord (5.1.4)
|
14
|
-
activemodel (= 5.1.4)
|
15
|
-
activesupport (= 5.1.4)
|
16
|
-
arel (~> 8.0)
|
17
|
-
activesupport (5.1.4)
|
18
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
19
|
-
i18n (~> 0.7)
|
20
|
-
minitest (~> 5.1)
|
21
|
-
tzinfo (~> 1.1)
|
22
|
-
arel (8.0.0)
|
23
|
-
concurrent-ruby (1.0.5)
|
24
|
-
i18n (0.9.0)
|
25
|
-
concurrent-ruby (~> 1.0)
|
26
|
-
minitest (5.10.3)
|
27
|
-
rake (10.5.0)
|
28
|
-
tableless (0.1.0)
|
29
|
-
activerecord (~> 5.0)
|
30
|
-
thread_safe (0.3.6)
|
31
|
-
tzinfo (1.2.3)
|
32
|
-
thread_safe (~> 0.1)
|
33
|
-
|
34
|
-
PLATFORMS
|
35
|
-
ruby
|
36
|
-
|
37
|
-
DEPENDENCIES
|
38
|
-
bundler (~> 1.14)
|
39
|
-
minitest (~> 5.0)
|
40
|
-
rake (~> 10.0)
|
41
|
-
smart_settings!
|
42
|
-
|
43
|
-
BUNDLED WITH
|
44
|
-
1.15.4
|