rails-settings-cached 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/rails-settings/cached_settings.rb +2 -4
- data/lib/rails-settings-cached.rb +7 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80bfa0c52c2d8fe8b4535ff364b0d727476f9e5c
|
4
|
+
data.tar.gz: ca264291977f18ee792e52191e6415974263ca13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88de4555fb37729d39d6f1f2f6868fac66399662c2d0139bb59783e07760cd6ca225c45ad2e1d42b10095be5bf8dbe6e356f2961347805ef7394045ce145ac3f
|
7
|
+
data.tar.gz: 4bdbfc25e039ac4b95baad02f27002a81710cd5ad0378b95f18ccab8583edeef080daba0697f149240c646783c9292ebdc98f5064093078e1587669d5875984a
|
data/README.md
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
module RailsSettings
|
2
2
|
class CachedSettings < Settings
|
3
|
-
after_commit :rewrite_cache, on: %i(create update)
|
4
3
|
def rewrite_cache
|
5
4
|
Rails.cache.write("rails_settings_cached:#{var}", value)
|
6
5
|
end
|
7
6
|
|
8
|
-
after_commit :expire_cache, on: %i(destroy)
|
9
7
|
def expire_cache
|
10
8
|
Rails.cache.delete("rails_settings_cached:#{var}")
|
11
9
|
end
|
@@ -21,8 +19,8 @@ module RailsSettings
|
|
21
19
|
end
|
22
20
|
|
23
21
|
def save_default(key, value)
|
24
|
-
return false unless
|
25
|
-
|
22
|
+
return false unless self[key].nil?
|
23
|
+
self[key] = value
|
26
24
|
end
|
27
25
|
end
|
28
26
|
end
|
@@ -2,3 +2,10 @@ require_relative 'rails-settings/settings'
|
|
2
2
|
require_relative 'rails-settings/scoped_settings'
|
3
3
|
require_relative 'rails-settings/cached_settings'
|
4
4
|
require_relative 'rails-settings/extend'
|
5
|
+
|
6
|
+
class RailsSettings::Railtie < Rails::Railtie
|
7
|
+
initializer "rails_settings.active_record.initialization" do
|
8
|
+
RailsSettings::CachedSettings.after_commit :rewrite_cache, on: %i(create update)
|
9
|
+
RailsSettings::CachedSettings.after_commit :expire_cache, on: %i(destroy)
|
10
|
+
end
|
11
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-settings-cached
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Squeegy
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2015-
|
14
|
+
date: 2015-09-10 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rails
|