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 +1 -1
- data/cached_values.gemspec +1 -1
- data/lib/cached_value.rb +10 -3
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.9.
|
1
|
+
1.9.1
|
data/cached_values.gemspec
CHANGED
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
|
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:
|
4
|
+
hash: 49
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
version: 1.9.
|
9
|
+
- 1
|
10
|
+
version: 1.9.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jack Danger Canty
|