rails-settings-cached 2.9.2 → 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: 212d83f192f7446ef64cdb9d2217a8dfe9324a1b8c64b2389857ca2997e5f46a
4
- data.tar.gz: 4a757c45119a1c31d5ce5d4d3a02af47adcd631856c8c3f403bb5303a0ff4e6c
3
+ metadata.gz: 58ce3e460f1a7fe4c3b97948640a87bb64c7253a1fe1fb0dbb0cfb29673e3c27
4
+ data.tar.gz: '0958cea09314dd287f2c3386aa50cfd5ae229454e4b1a7ce72559aafca9bfd81'
5
5
  SHA512:
6
- metadata.gz: 29aa302129ae5ee8950137df21d529b60c90cc3b251acf9760c20b857f75be8f4407a9f4ed2ed518646c1baa411c42513bd04886c22e9d8923c36a4962bb74f4
7
- data.tar.gz: 2f205f829b23ed7d3cf691b9e9c7d6f4ac236b6767bd2240b65fee039390416453bce3a99dfdfeb892e0c8aa29950ecbfa5693dd302fea1ee853e7f671bd1a23
6
+ metadata.gz: 8ad68d40b2b8aa0a1a6cb69a634ac712b3643086bcd0e8c681659f1f88bfcdea171fca2cc96cfbd031ef53cebdf15e6ab948037dc141d9712d9a8ce48a380007
7
+ data.tar.gz: 43acf6e8a2f864ec74c8118bc63db112ecfacbe199937752e077163e3a689a894a2e9830b899b55b03fb1c5399e95a367b883c0467e613ae051c5823de26e61f
@@ -15,8 +15,16 @@ module RailsSettings
15
15
 
16
16
  @@migrations = false
17
17
 
18
+ def self.timestamped_migrations
19
+ if ActiveRecord::Base.respond_to?(:timestamped_migrations)
20
+ ActiveRecord::Base.timestamped_migrations
21
+ elsif ActiveRecord.respond_to?(:timestamped_migrations)
22
+ ActiveRecord.timestamped_migrations
23
+ end
24
+ end
25
+
18
26
  def self.next_migration_number(dirname) #:nodoc:
19
- if ActiveRecord::Base.timestamped_migrations
27
+ if timestamped_migrations
20
28
  if @@migrations
21
29
  (current_migration_number(dirname) + 1)
22
30
  else
@@ -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.2"
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.2
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-06-02 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
@@ -158,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
159
  - !ruby/object:Gem::Version
159
160
  version: '0'
160
161
  requirements: []
161
- rubygems_version: 3.4.1
162
+ rubygems_version: 3.4.19
162
163
  signing_key:
163
164
  specification_version: 4
164
165
  summary: The best solution for store global settings in Rails applications.