rails-settings-cached 2.9.4 → 2.9.5

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: 58ce3e460f1a7fe4c3b97948640a87bb64c7253a1fe1fb0dbb0cfb29673e3c27
4
- data.tar.gz: '0958cea09314dd287f2c3386aa50cfd5ae229454e4b1a7ce72559aafca9bfd81'
3
+ metadata.gz: dc947f6d7c17fd74d160cedbbafe9b027a24fa4e56192ab4cf515f72ac3eb7b3
4
+ data.tar.gz: 2464010525a411701cad88349ff304ada0bf872b1cebdfff6627014ebfe971fe
5
5
  SHA512:
6
- metadata.gz: 8ad68d40b2b8aa0a1a6cb69a634ac712b3643086bcd0e8c681659f1f88bfcdea171fca2cc96cfbd031ef53cebdf15e6ab948037dc141d9712d9a8ce48a380007
7
- data.tar.gz: 43acf6e8a2f864ec74c8118bc63db112ecfacbe199937752e077163e3a689a894a2e9830b899b55b03fb1c5399e95a367b883c0467e613ae051c5823de26e61f
6
+ metadata.gz: 6e8b7bdccafeffde0dbb610057b1dfd7c4b5b147663dea19880ad94b44186861efb1ec8b6321dc1aa0095938070522aa4bdf3d708db0eb1c74ec77505bbff8d0
7
+ data.tar.gz: 83dd5c6cf2faf96424b95dc9a6caaafb30c15f0eb05102eb7285b49cfc479423af3415cbdde3d6b6bb3f1342b437cd982b883572e9214eaa720267e83249fbdc
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
- - [daqing/rabel](https://github.com/daqing/rabel) - 0.4.x
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.
@@ -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
@@ -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
@@ -3,7 +3,7 @@
3
3
  module RailsSettings
4
4
  class << self
5
5
  def version
6
- "2.9.4"
6
+ "2.9.5"
7
7
  end
8
8
  end
9
9
  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
4
+ version: 2.9.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Lee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-16 00:00:00.000000000 Z
11
+ date: 2024-10-07 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.4.19
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.