activerecord-cached_at 2.0.6 → 2.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cached_at/associations/association.rb +14 -0
- data/lib/cached_at/base.rb +1 -15
- data/lib/cached_at/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc1bd151e181ac5f23c935dac9ab23fbcddccbc5
|
4
|
+
data.tar.gz: 208b03130f07a7e15de10eecf04f4c7b63d791a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7888c7177e10ad7dc44bc866f73b73ed046344ce365a347948cc0459e0d7267822741abe42585e24b30e55460bbe2e41240cb097d88b7b68ccc6c2078cca491
|
7
|
+
data.tar.gz: 55cbee3514f01d8c156e7379d6d1d59e8a512693e944d017afaedf31adf5c2dbacc3d02e9e58ed4b032dab79c5cf58a15a08933b41969b228d5dc2059629bc6d
|
@@ -35,6 +35,20 @@ module CachedAt
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
+
def touch_through_reflections(reflections, timestamp)
|
39
|
+
reflections.each do |r|
|
40
|
+
cache_column = "#{r.inverse_of.name}_cached_at"
|
41
|
+
|
42
|
+
source_assoc = owner.association(r.source_reflection_name.to_sym)
|
43
|
+
if source_assoc.loaded?
|
44
|
+
source_assoc.target.raw_write_attribute(cache_column, timestamp)
|
45
|
+
end
|
46
|
+
query = r.klass.where(r.association_primary_key => owner.send(r.foreign_key))
|
47
|
+
query.update_all({ cache_column => timestamp })
|
48
|
+
traverse_relationships(r.klass, r.options[:cached_at], query, cache_column, timestamp)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
38
52
|
end
|
39
53
|
end
|
40
54
|
|
data/lib/cached_at/base.rb
CHANGED
@@ -51,21 +51,7 @@ module CachedAt
|
|
51
51
|
|
52
52
|
assoc = association(name.to_sym)
|
53
53
|
assoc.touch_cached_at(timestamp, method)
|
54
|
-
|
55
|
-
through_connections.each do |r|
|
56
|
-
#TODO: move into association
|
57
|
-
cache_column = "#{r.inverse_of.name}_cached_at"
|
58
|
-
|
59
|
-
r.klass.where(r.association_primary_key => self.send(r.foreign_key)).update_all({
|
60
|
-
cache_column => timestamp
|
61
|
-
})
|
62
|
-
|
63
|
-
source_assoc = association(r.source_reflection_name.to_sym)
|
64
|
-
if source_assoc.loaded?
|
65
|
-
source_assoc.target.raw_write_attribute(cache_column, timestamp)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
54
|
+
assoc.touch_through_reflections(through_connections, timestamp)
|
69
55
|
end
|
70
56
|
end
|
71
57
|
|
data/lib/cached_at/version.rb
CHANGED