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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c8b23098050aa4759654409c3c89868a28f75053
4
- data.tar.gz: 3aea3f6687a9248d88ff6512130a3646e53c7107
3
+ metadata.gz: 73c0c36c565d579b31448c414e6724af24ea9668
4
+ data.tar.gz: ab9bca289a5c4c90862145bf7863f6ff52771af3
5
5
  SHA512:
6
- metadata.gz: caf5df986fc15f69e417409c6617a3c40026e6d9383d82007970699860a3fcff6390cf6393fe200200256be373c79979c26560d7db1c8e6ba71cdae1be288d5b
7
- data.tar.gz: a74798f521363fdf8a44a6bbae620b9fca61b56ce29553805416c23bdb5702d6bc15502f2bf5a1339e68fe9a1331e135721de46394c6d700f2782f003f1bbaa2
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
- gem "rails-settings-cached"
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
- obj = Rails.cache.fetch("settings:#{var_name}") {
12
+ cache_key = "settings:#{var_name}"
13
+ obj = Rails.cache.fetch(cache_key) {
13
14
  super(var_name)
14
15
  }
15
- obj || @@defaults[var_name.to_s]
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, -> (var) {
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, -> (var) {
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}'")
@@ -2,7 +2,6 @@ module RailsSettings
2
2
  class Settings < ActiveRecord::Base
3
3
 
4
4
  self.table_name = 'settings'
5
- # attr_accessible :var
6
5
 
7
6
  class SettingNotFound < RuntimeError; end
8
7
 
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.0
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-02-26 00:00:00.000000000 Z
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.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