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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9b337e6a81a89e040b93931c3b5b6149256e165b
4
- data.tar.gz: 30ca746f43b88c5fe033bf379672548533c404f0
3
+ metadata.gz: dc1bd151e181ac5f23c935dac9ab23fbcddccbc5
4
+ data.tar.gz: 208b03130f07a7e15de10eecf04f4c7b63d791a6
5
5
  SHA512:
6
- metadata.gz: 57af1b7560442a3c96e92ec0a7d586ce8459d9e202f64e26e7c15d5908a923abc2aa6a511c830565755dab92746f7e8c4a0a7da29e48e90a0a775b9cd038fddf
7
- data.tar.gz: 1d6c1ed6214bcf774a099e138d1762dd6ec92a80425c35b7b59510bc8f859957f6a631068a2133f45952b696e1ace1be3eb71ed4a805ffa0a3547f319cd841e8
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
 
@@ -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
 
@@ -1,3 +1,3 @@
1
1
  module CachedAt
2
- VERSION = '2.0.6'
2
+ VERSION = '2.0.7'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-cached_at
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.6
4
+ version: 2.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Bracy