rails-settings-cached 2.9.3 → 2.9.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 56978bb6963c13b5f83ae09b460fbdc6cfe5841233bbfb7e54db4a18648a56f7
4
- data.tar.gz: 8269965e9356e03eeb50cc9f5a819b7a875cdac92911446841cea9f0776e5d24
3
+ metadata.gz: 58ce3e460f1a7fe4c3b97948640a87bb64c7253a1fe1fb0dbb0cfb29673e3c27
4
+ data.tar.gz: '0958cea09314dd287f2c3386aa50cfd5ae229454e4b1a7ce72559aafca9bfd81'
5
5
  SHA512:
6
- metadata.gz: 5cce734046980fafc3a1c7678599220cb61ff7aad75115b1a61aa07517ec6d4abd7650d221deee0bfe65d465e218e82413556a6b6dab408f9e167cdb8ad037f9
7
- data.tar.gz: 8c2af6ec2dff0e1111c2b1972959396995456296ea2a3f307852cfa1ce3fdf63036bc9aeebf1c9edfcb74ce2f0cb17bf7b34ce257c632ea297253cd32e0266bc
6
+ metadata.gz: 8ad68d40b2b8aa0a1a6cb69a634ac712b3643086bcd0e8c681659f1f88bfcdea171fca2cc96cfbd031ef53cebdf15e6ab948037dc141d9712d9a8ce48a380007
7
+ data.tar.gz: 43acf6e8a2f864ec74c8118bc63db112ecfacbe199937752e077163e3a689a894a2e9830b899b55b03fb1c5399e95a367b883c0467e613ae051c5823de26e61f
@@ -33,7 +33,7 @@ module RailsSettings
33
33
  class << self
34
34
  def clear_cache
35
35
  RequestCache.reset
36
- Rails.cache.delete(cache_key)
36
+ cache_storage.delete(cache_key)
37
37
  end
38
38
 
39
39
  def field(key, **opts)
@@ -127,13 +127,17 @@ module RailsSettings
127
127
  end
128
128
 
129
129
  def _all_settings
130
- RequestCache.all_settings ||= Rails.cache.fetch(cache_key, expires_in: 1.week) do
130
+ RequestCache.all_settings ||= cache_storage.fetch(cache_key, expires_in: 1.week) do
131
131
  vars = unscoped.select("var, value")
132
132
  result = {}
133
133
  vars.each { |record| result[record.var] = record.value }
134
134
  result.with_indifferent_access
135
135
  end
136
136
  end
137
+
138
+ def cache_storage
139
+ RailsSettings.config.cache_storage
140
+ end
137
141
  end
138
142
  end
139
143
  end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsSettings
4
+ class Configuration
5
+ # Caching storage backend.
6
+ # Default: `Rails.cache`
7
+ attr_accessor :cache_storage
8
+ end
9
+
10
+ class << self
11
+ def config
12
+ return @config if defined?(@config)
13
+
14
+ @config = Configuration.new
15
+ @config.cache_storage = Rails.cache
16
+ @config
17
+ end
18
+
19
+ def configure(&block)
20
+ config.instance_exec(&block)
21
+ end
22
+ end
23
+ end
@@ -3,7 +3,7 @@
3
3
  module RailsSettings
4
4
  class << self
5
5
  def version
6
- "2.9.3"
6
+ "2.9.4"
7
7
  end
8
8
  end
9
9
  end
@@ -10,6 +10,7 @@ require_relative "rails-settings/fields/integer"
10
10
  require_relative "rails-settings/fields/string"
11
11
 
12
12
  require_relative "rails-settings/base"
13
+ require_relative "rails-settings/configuration"
13
14
  require_relative "rails-settings/request_cache"
14
15
  require_relative "rails-settings/middleware"
15
16
  require_relative "rails-settings/railtie"
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.3
4
+ version: 2.9.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: 2023-10-03 00:00:00.000000000 Z
11
+ date: 2023-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -127,6 +127,7 @@ files:
127
127
  - lib/generators/settings/templates/model.rb
128
128
  - lib/rails-settings-cached.rb
129
129
  - lib/rails-settings/base.rb
130
+ - lib/rails-settings/configuration.rb
130
131
  - lib/rails-settings/fields/array.rb
131
132
  - lib/rails-settings/fields/base.rb
132
133
  - lib/rails-settings/fields/big_decimal.rb