rails-settings-cached 2.3.3 → 2.3.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d9fb44e09bad24a4d3c6cf36fda107fe18ce214964b713de318e5f3efc083851
4
- data.tar.gz: 75ee5df473cff1fc07b963b6441152f559de8d0a5652267530c5c0f62cac93f9
3
+ metadata.gz: '08fedca17d5c8848f9503a0b9a2d45403fd545406ec656d899af182334d6c3ac'
4
+ data.tar.gz: 1b928531e53c09d4ac3c582785aad54dee23f81c00721857009c0495ee1a7f30
5
5
  SHA512:
6
- metadata.gz: 6bf0b841b4b2ee46b7da5f51a54d2e3f17f984f2fe1f72841bc056966efc29fd5ad70ea54b0b5559f4ea493927ef796cbc956302b404e18ec61059c40d620904
7
- data.tar.gz: 76a594a2df28a1490c6d67b1fff1a4d776572cc1240c9c07549d6d0349c048a017ee10f828d7c38e41bdf4c7158af9108f9c9181af3ee015af72654cd23831ff
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
  ```
@@ -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")
@@ -3,7 +3,7 @@
3
3
  module RailsSettings
4
4
  class << self
5
5
  def version
6
- "2.3.3"
6
+ "2.3.4"
7
7
  end
8
8
  end
9
9
  end
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.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-16 00:00:00.000000000 Z
11
+ date: 2020-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails