rails-settings-cached 2.0.0 → 2.0.1
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/lib/generators/settings/templates/model.rb +2 -0
- data/lib/rails-settings/base.rb +16 -12
- data/lib/rails-settings/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc90c161735c2de3ceef1814d8c93706422860bfa444407717862ded1ee4efb4
|
4
|
+
data.tar.gz: 50538a15a02ad109a05ef5d09bebe2a2dc4530f8b393348f4a86b32521fb3917
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3b3c1d7730b48f11a90c5d1a0ff9ee07dccade17b7dd31ce6fb8988449a12a265cbb8349c61416d7663ea7e629fa92f41ea4756e44c2b862522f7172a81f3ee
|
7
|
+
data.tar.gz: 116a49dc9ea61533e11c0ccad5ec0138093db6f051b6319219259e084e2c4fa2bca06e098d939b6de0c1e3ca4dadd533a0fa0c5db939c2ea15c187c623e9c1cf
|
@@ -7,4 +7,6 @@ class <%= class_name %> < RailsSettings::Base
|
|
7
7
|
# field :default_locale, default: "en", type: :string
|
8
8
|
# field :confirmable_enable, default: "0", type: :boolean
|
9
9
|
# field :admin_emails, default: "admin@rubyonrails.org", type: :array
|
10
|
+
# field :omniauth_google_client_id, default: (ENV["OMNIAUTH_GOOGLE_CLIENT_ID"] || ""), type: :string, readonly: true
|
11
|
+
# field :omniauth_google_client_secret, default: (ENV["OMNIAUTH_GOOGLE_CLIENT_SECRET"] || ""), type: :string, readonly: true
|
10
12
|
end
|
data/lib/rails-settings/base.rb
CHANGED
@@ -39,22 +39,26 @@ module RailsSettings
|
|
39
39
|
|
40
40
|
private
|
41
41
|
def _define_field(key, default: nil, type: :string, readonly: false)
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
if !val.nil?
|
46
|
-
result = val
|
47
|
-
else
|
48
|
-
result = default
|
49
|
-
result = default.call if default.is_a?(Proc)
|
42
|
+
if readonly
|
43
|
+
self.class.define_method(key) do
|
44
|
+
self.send(:_covert_string_to_typeof_value, type, default)
|
50
45
|
end
|
46
|
+
else
|
47
|
+
self.class.define_method(key) do
|
48
|
+
val = self.send(:_value_of, key)
|
49
|
+
result = nil
|
50
|
+
if !val.nil?
|
51
|
+
result = val
|
52
|
+
else
|
53
|
+
result = default
|
54
|
+
result = default.call if default.is_a?(Proc)
|
55
|
+
end
|
51
56
|
|
52
|
-
|
57
|
+
result = self.send(:_covert_string_to_typeof_value, type, result)
|
53
58
|
|
54
|
-
|
55
|
-
|
59
|
+
result
|
60
|
+
end
|
56
61
|
|
57
|
-
unless readonly
|
58
62
|
self.class.define_method("#{key}=") do |value|
|
59
63
|
var_name = key.to_s
|
60
64
|
|