rails-settings-cached 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -1
- data/lib/rails-settings/cached_settings.rb +3 -2
- data/lib/rails-settings/extend.rb +2 -2
- data/lib/rails-settings/settings.rb +0 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73c0c36c565d579b31448c414e6724af24ea9668
|
4
|
+
data.tar.gz: ab9bca289a5c4c90862145bf7863f6ff52771af3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7833bac30207ab89f8ef00e3957649493c12419f1f263bcd759171f86f7da671249cf6fd76e2762b14688fc4c175d077d6086949925f7071ba57ffff1de88d7
|
7
|
+
data.tar.gz: adffcfa08e380a85f2d4daaaf38cb6ec857b872c4aa8a297391a1cf36231343d271e3ee092c862ce6527470e95e9d9eae89e068bf9e78423fffd1e3f83bc2c14
|
data/README.md
CHANGED
@@ -16,7 +16,10 @@ arrays, or any object. Ported to Rails 3!
|
|
16
16
|
Edit your Gemfile:
|
17
17
|
|
18
18
|
```ruby
|
19
|
-
|
19
|
+
# Rails 4+
|
20
|
+
gem "rails-settings-cached", "0.3.0"
|
21
|
+
# Rails 3.x
|
22
|
+
gem "rails-settings-cached", "0.2.4"
|
20
23
|
```
|
21
24
|
|
22
25
|
Generate your settings:
|
@@ -9,10 +9,11 @@ module RailsSettings
|
|
9
9
|
after_destroy { |record| Rails.cache.delete("settings:#{record.var}") }
|
10
10
|
|
11
11
|
def self.[](var_name)
|
12
|
-
|
12
|
+
cache_key = "settings:#{var_name}"
|
13
|
+
obj = Rails.cache.fetch(cache_key) {
|
13
14
|
super(var_name)
|
14
15
|
}
|
15
|
-
obj
|
16
|
+
obj == nil ? @@defaults[var_name.to_s] : obj
|
16
17
|
end
|
17
18
|
|
18
19
|
def self.save_default(key,value)
|
@@ -10,7 +10,7 @@ module RailsSettings
|
|
10
10
|
}
|
11
11
|
|
12
12
|
|
13
|
-
scope :with_settings_for, ->
|
13
|
+
scope :with_settings_for, ->(var) {
|
14
14
|
joins("JOIN settings ON (settings.thing_id = #{self.table_name}.#{self.primary_key} AND
|
15
15
|
settings.thing_type = '#{self.base_class.name}') AND settings.var = '#{var}'")
|
16
16
|
}
|
@@ -20,7 +20,7 @@ module RailsSettings
|
|
20
20
|
.where("settings.id IS NULL")
|
21
21
|
}
|
22
22
|
|
23
|
-
scope :without_settings_for, ->
|
23
|
+
scope :without_settings_for, ->(var) {
|
24
24
|
where('settings.id IS NULL')
|
25
25
|
.joins("LEFT JOIN settings ON (settings.thing_id = #{self.table_name}.#{self.primary_key} AND
|
26
26
|
settings.thing_type = '#{self.base_class.name}') AND settings.var = '#{var}'")
|
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.3.
|
4
|
+
version: 0.3.1
|
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: 2013-
|
14
|
+
date: 2013-06-26 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rails
|
@@ -61,7 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
61
61
|
version: '0'
|
62
62
|
requirements: []
|
63
63
|
rubyforge_project:
|
64
|
-
rubygems_version: 2.0.
|
64
|
+
rubygems_version: 2.0.3
|
65
65
|
signing_key:
|
66
66
|
specification_version: 4
|
67
67
|
summary: This is imporved from rails-settings, added caching. Settings is a plugin
|