rails-settings-cached 0.4.3 → 0.4.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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7fba2dd4d13c0c1a77876382d0207c0815a75d34
|
4
|
+
data.tar.gz: b1ccc3d46ba88211fd29952b0eabf020cef3acab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a0342009a9dc86b0f531583cb3de8137944641e8d667acb486b739f7b4bbb4bb611dd33511c7ef41fc6a77a72ea7b842d20f79ee8f3f915d7e9bc03d3c4d618e
|
7
|
+
data.tar.gz: 54a0558fee9b43f595801fbe84c40e6907ddc226eeeedbeed458dc466cf2bea35532d6603728cc4e6222948d68528cdc3dee46c26c5cf1dde0f43dca773585ad
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require_relative 'rails-settings/settings'
|
2
|
-
require_relative 'rails-settings/scoped_settings'
|
3
2
|
require_relative 'rails-settings/cached_settings'
|
3
|
+
require_relative 'rails-settings/scoped_settings'
|
4
4
|
require_relative 'rails-settings/extend'
|
5
5
|
|
6
6
|
class RailsSettings::Railtie < Rails::Railtie
|
@@ -1,17 +1,26 @@
|
|
1
1
|
module RailsSettings
|
2
2
|
class CachedSettings < Settings
|
3
3
|
def rewrite_cache
|
4
|
-
Rails.cache.write(
|
4
|
+
Rails.cache.write(cache_key, value)
|
5
5
|
end
|
6
6
|
|
7
7
|
def expire_cache
|
8
|
-
Rails.cache.delete(
|
8
|
+
Rails.cache.delete(cache_key)
|
9
|
+
end
|
10
|
+
|
11
|
+
def cache_key
|
12
|
+
self.class.cache_key(var, thing)
|
9
13
|
end
|
10
14
|
|
11
15
|
class << self
|
16
|
+
def cache_key(var_name, scope_object)
|
17
|
+
scope = "rails_settings_cached:"
|
18
|
+
scope << "#{scope_object.class.base_class.to_s}-#{scope_object.id}:" if scope_object
|
19
|
+
scope << "#{var_name}"
|
20
|
+
end
|
21
|
+
|
12
22
|
def [](var_name)
|
13
|
-
|
14
|
-
obj = Rails.cache.read(cache_key)
|
23
|
+
obj = Rails.cache.read(cache_key(var_name, @object))
|
15
24
|
obj = super(var_name) if obj.nil?
|
16
25
|
|
17
26
|
return @@defaults[var_name.to_s] if obj.nil?
|
@@ -7,6 +7,8 @@ module RailsSettings
|
|
7
7
|
cattr_accessor :defaults
|
8
8
|
@@defaults = {}.with_indifferent_access
|
9
9
|
|
10
|
+
belongs_to :thing, polymorphic: true
|
11
|
+
|
10
12
|
# Support old plugin
|
11
13
|
if defined?(SettingsDefaults::DEFAULTS)
|
12
14
|
@@defaults = SettingsDefaults::DEFAULTS.with_indifferent_access
|
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.4
|
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-09-
|
14
|
+
date: 2015-09-14 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rails
|