cache_associations 0.3 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cache_associations.rb +5 -3
- data/lib/cache_associations/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: cd12d459e007b638dd6288d6e78831ae230e8233
|
4
|
+
data.tar.gz: e6d9d9823b011d71ad13b06f25235710870380a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df3c9ec190039a151c008d6fb5f2787e30a4750b33a60118e189ce3f7f8780aaf5c063109905e21aa7e19bda501791aa84aa6b2967d4bcc9fbe04a699d634178
|
7
|
+
data.tar.gz: 97560d261ba269437bc73f72fe8b2a478bf199fccb8c72e2f551fa813d30b188e5c2e3df23bcb39efb2f93449cb097ced438272581d3a856b1c281b47806b12c
|
data/lib/cache_associations.rb
CHANGED
@@ -41,12 +41,14 @@ module CacheAssociations
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def cache_global_association(name, global_key = nil, **options)
|
44
|
+
reflection = reflect_on_association(name)
|
45
|
+
foreign_key = reflection.foreign_key
|
46
|
+
|
44
47
|
if global_key.blank?
|
45
|
-
|
46
|
-
else
|
47
|
-
cache_name_block = lambda { global_key }
|
48
|
+
global_key = reflection.klass.name
|
48
49
|
end
|
49
50
|
|
51
|
+
cache_name_block = lambda { [global_key, send(foreign_key)] }
|
50
52
|
cache_association(name, **options, &cache_name_block)
|
51
53
|
end
|
52
54
|
|