cached_values 1.9.0 → 1.9.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.9.0
1
+ 1.9.1
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{cached_values}
8
- s.version = "1.9.0"
8
+ s.version = "1.9.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jack Danger Canty"]
data/lib/cached_value.rb CHANGED
@@ -10,8 +10,10 @@ module ActiveRecord
10
10
 
11
11
  def load(force_update = false)
12
12
  @target = find_target force_update
13
- if force_update || (has_cache? && find_target_from_cache.nil?)
13
+ if force_update
14
14
  update_cache @target
15
+ elsif has_cache? && find_target_from_cache.nil?
16
+ soft_update @target
15
17
  end
16
18
  self
17
19
  end
@@ -80,12 +82,17 @@ module ActiveRecord
80
82
  def clear_cache
81
83
  update_cache(nil)
82
84
  end
85
+
86
+ def soft_update(value)
87
+ return unless has_cache?
88
+ return unless CachedValues.run?
89
+ @owner.send(:write_attribute, cache_column, value)
90
+ end
83
91
 
84
92
  def update_cache(value)
85
93
  return unless has_cache?
86
94
  return unless CachedValues.run?
87
-
88
- @owner.send(:write_attribute, cache_column, value)
95
+ soft_update value
89
96
 
90
97
  return if @owner.new_record? || !CachedValues.perform_save?
91
98
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cached_values
3
3
  version: !ruby/object:Gem::Version
4
- hash: 51
4
+ hash: 49
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 9
9
- - 0
10
- version: 1.9.0
9
+ - 1
10
+ version: 1.9.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jack Danger Canty