rails-settings-cached 2.3.3 → 2.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +20 -0
- data/lib/rails-settings/base.rb +7 -2
- data/lib/rails-settings/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '08fedca17d5c8848f9503a0b9a2d45403fd545406ec656d899af182334d6c3ac'
|
4
|
+
data.tar.gz: 1b928531e53c09d4ac3c582785aad54dee23f81c00721857009c0495ee1a7f30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f742e343ecfe97413a17aafefead8f5e49a49d407e269962a90e08a3f8ad89441f0ba95f4496a80b8528f68d5edecccf930f00af39627020d75a8e947ac28a5
|
7
|
+
data.tar.gz: 970ef16a4a2f2c3c552f0d80d8386d5124e3821c0f9ed54d2ad3b0dd57e3c37a7cf94a6342c14d4cb585a6e188c2659ba13034607768eb2dfd29680c5c084a5f
|
data/README.md
CHANGED
@@ -173,6 +173,26 @@ class Setting < RailsSettings::Base
|
|
173
173
|
end
|
174
174
|
```
|
175
175
|
|
176
|
+
## Use Setting in Rails initalizing:
|
177
|
+
|
178
|
+
You can't use Setting in these locations:
|
179
|
+
|
180
|
+
```
|
181
|
+
config/application.rb
|
182
|
+
config/environments/*.rb
|
183
|
+
```
|
184
|
+
|
185
|
+
If you wants do that, put the setting into `config/initializers/*.rb`
|
186
|
+
|
187
|
+
For example:
|
188
|
+
|
189
|
+
```rb
|
190
|
+
# config/initializers/devise.rb
|
191
|
+
Devise.setup do |config|
|
192
|
+
config.omniauth :twitter, Setting.twitter_api_key, Setting.twitter_api_secret
|
193
|
+
end
|
194
|
+
```
|
195
|
+
|
176
196
|
### Caching flow:
|
177
197
|
|
178
198
|
```
|
data/lib/rails-settings/base.rb
CHANGED
@@ -149,6 +149,13 @@ module RailsSettings
|
|
149
149
|
end
|
150
150
|
|
151
151
|
_all_settings[var_name.to_s]
|
152
|
+
rescue => e
|
153
|
+
if e.message.include?("connect")
|
154
|
+
puts "WARNING: `#{name}.#{var_name}` called but no connection, fallback to returns the default value."
|
155
|
+
return nil
|
156
|
+
end
|
157
|
+
|
158
|
+
raise e
|
152
159
|
end
|
153
160
|
|
154
161
|
def rails_initialized?
|
@@ -156,8 +163,6 @@ module RailsSettings
|
|
156
163
|
end
|
157
164
|
|
158
165
|
def _all_settings
|
159
|
-
raise "You cannot use settings before Rails initialize." unless rails_initialized?
|
160
|
-
|
161
166
|
RequestStore.store[:rails_settings_all_settings] ||= begin
|
162
167
|
Rails.cache.fetch(cache_key, expires_in: 1.week) do
|
163
168
|
vars = unscoped.select("var, value")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-settings-cached
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Lee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-10-
|
11
|
+
date: 2020-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|