rails-settings-cached 2.9.4 → 2.9.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +3 -1
- data/README.md +13 -1
- data/lib/rails-settings/base.rb +2 -6
- data/lib/rails-settings/fields/base.rb +3 -3
- data/lib/rails-settings/railtie.rb +0 -4
- data/lib/rails-settings/version.rb +1 -1
- data/lib/rails-settings-cached.rb +8 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d05d1205c697134a64a5b91c47318c54b91d8ad7f7c8864c267d412811d489d
|
4
|
+
data.tar.gz: 36ba97af3af1eaba42038f09622555a072219d1ab95f69dacd63710e3f0c3e27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 144d2d98f2915856c9e59c5b7a7d1b4fffcb48ef060d13a79ac08d58f5588481ea57fbbb742e6132aa152c18cbed414eeb792a532745ec97446a3db2176564d7
|
7
|
+
data.tar.gz: 9e3531e3905ef62d7273f87e4bec539ebbcebf7c7b2a32d0d78e22e09a52bbe99736c17af586b9963adc1e35149980f75376d0de8575b14b691c8ad9633d67df
|
data/MIT-LICENSE
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
Original Copyright (c) 2006 Alex Wayne
|
2
|
+
Some additional features added 2009 by Georg Ledermann
|
1
3
|
Copyright (c) 2019 Jason Lee
|
2
4
|
|
3
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
@@ -17,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOa AND
|
|
17
19
|
NONINFRINGEMENT. IN NO EVENT SaALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
20
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
21
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -465,6 +465,18 @@ app/views/admin/settings/show.html.erb
|
|
465
465
|
<% end %>
|
466
466
|
```
|
467
467
|
|
468
|
+
## Special Cache Storage
|
469
|
+
|
470
|
+
You can use `cache_store` to change cache storage, default is `Rails.cache`.
|
471
|
+
|
472
|
+
Add `config/initializers/rails_settings.rb`
|
473
|
+
|
474
|
+
```rb
|
475
|
+
RailsSettings.configure do
|
476
|
+
self.cache_storage = ActiveSupport::Cache::RedisCacheStore.new(url: "redis://localhost:6379")
|
477
|
+
end
|
478
|
+
```
|
479
|
+
|
468
480
|
## Scoped Settings
|
469
481
|
|
470
482
|
> 🚨 BREAK CHANGES WARNING:
|
@@ -505,6 +517,6 @@ end
|
|
505
517
|
- [texterify/texterify](https://github.com/texterify/texterify) - 2.x
|
506
518
|
- [mastodon/mastodon](https://github.com/mastodon/mastodon) - 0.6.x
|
507
519
|
- [helpyio/helpy](https://github.com/helpyio/helpy) - 0.5.x
|
508
|
-
- [
|
520
|
+
- [maybe-finance/maybe](https://github.com/maybe-finance/maybe) - 2.x
|
509
521
|
|
510
522
|
And more than [1K repositories](https://github.com/huacnlee/rails-settings-cached/network/dependents) used.
|
data/lib/rails-settings/base.rb
CHANGED
@@ -1,16 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module RailsSettings
|
4
|
-
class ProtectedKeyError < RuntimeError
|
5
|
-
def initialize(key)
|
6
|
-
super("Can't use #{key} as setting key.")
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
4
|
class Base < ActiveRecord::Base
|
11
5
|
PROTECTED_KEYS = %w[var value]
|
12
6
|
self.table_name = table_name_prefix + "settings"
|
13
7
|
|
8
|
+
after_commit :clear_cache, on: %i[create update destroy]
|
9
|
+
|
14
10
|
# get the value field, YAML decoded
|
15
11
|
def value
|
16
12
|
# rubocop:disable Security/YAMLLoad
|
@@ -33,9 +33,9 @@ module RailsSettings
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def read
|
36
|
-
|
37
|
-
|
38
|
-
deserialize(
|
36
|
+
stored_value = saved_value
|
37
|
+
return deserialize(default_value) if readonly || stored_value.nil?
|
38
|
+
deserialize(stored_value)
|
39
39
|
end
|
40
40
|
|
41
41
|
def deserialize(value)
|
@@ -2,10 +2,6 @@
|
|
2
2
|
|
3
3
|
module RailsSettings
|
4
4
|
class Railtie < Rails::Railtie
|
5
|
-
initializer "rails_settings.active_record.initialization" do
|
6
|
-
RailsSettings::Base.after_commit :clear_cache, on: %i[create update destroy]
|
7
|
-
end
|
8
|
-
|
9
5
|
initializer "rails_settings.configure_rails_initialization" do |app|
|
10
6
|
app.middleware.use RailsSettings::Middleware
|
11
7
|
end
|
@@ -9,7 +9,6 @@ require_relative "rails-settings/fields/hash"
|
|
9
9
|
require_relative "rails-settings/fields/integer"
|
10
10
|
require_relative "rails-settings/fields/string"
|
11
11
|
|
12
|
-
require_relative "rails-settings/base"
|
13
12
|
require_relative "rails-settings/configuration"
|
14
13
|
require_relative "rails-settings/request_cache"
|
15
14
|
require_relative "rails-settings/middleware"
|
@@ -17,6 +16,14 @@ require_relative "rails-settings/railtie"
|
|
17
16
|
require_relative "rails-settings/version"
|
18
17
|
|
19
18
|
module RailsSettings
|
19
|
+
class ProtectedKeyError < RuntimeError
|
20
|
+
def initialize(key)
|
21
|
+
super("Can't use #{key} as setting key.")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
autoload :Base, "rails-settings/base"
|
26
|
+
|
20
27
|
module Fields
|
21
28
|
end
|
22
29
|
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.9.
|
4
|
+
version: 2.9.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Lee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -159,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
159
159
|
- !ruby/object:Gem::Version
|
160
160
|
version: '0'
|
161
161
|
requirements: []
|
162
|
-
rubygems_version: 3.
|
162
|
+
rubygems_version: 3.5.3
|
163
163
|
signing_key:
|
164
164
|
specification_version: 4
|
165
165
|
summary: The best solution for store global settings in Rails applications.
|