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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 32b28bb91ce8272843abdf8a1bad4a378d7ef6c6
4
- data.tar.gz: f604864414fa453b35bb0427d845eddb26cdbdaa
3
+ metadata.gz: cd12d459e007b638dd6288d6e78831ae230e8233
4
+ data.tar.gz: e6d9d9823b011d71ad13b06f25235710870380a1
5
5
  SHA512:
6
- metadata.gz: 24dee2057a4960ea396a6c1bb22b56e37deb8343e67701b21d67a868d391e4ce2aef3d691b1642258061c44bf149156f3bb9103ef4533543388bf1e5d8e59c18
7
- data.tar.gz: 2fee5df99f3fffcb8620f1aed261430284533f7def49cb6920a6340dd36dc3a71a77cdd694ca8ca2e6b654402febb81d96c1f81e269d5d5e0bd4973b5af9d900
6
+ metadata.gz: df3c9ec190039a151c008d6fb5f2787e30a4750b33a60118e189ce3f7f8780aaf5c063109905e21aa7e19bda501791aa84aa6b2967d4bcc9fbe04a699d634178
7
+ data.tar.gz: 97560d261ba269437bc73f72fe8b2a478bf199fccb8c72e2f551fa813d30b188e5c2e3df23bcb39efb2f93449cb097ced438272581d3a856b1c281b47806b12c
@@ -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
- cache_name_block = lambda { [self.class.reflect_on_association(name).klass.name, id] }
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
 
@@ -1,3 +1,3 @@
1
1
  module CacheAssociations
2
- VERSION = "0.3"
2
+ VERSION = "0.3.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cache_associations
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.3'
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fuxin Hao