attr_cached 1.1 → 1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/attr_cached.rb +6 -0
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 725c00a3036d232745250c074f0a603d81fbb869
4
- data.tar.gz: 7ac7ae8b8f038ec2a6a5ed073fc7c1e86040fda5
3
+ metadata.gz: d242c82d648d83b5138bc10af56ecf57dd8c0cdd
4
+ data.tar.gz: afa543a7b7797523483bdae99d5d15f423417c2f
5
5
  SHA512:
6
- metadata.gz: 74c642d81ccc69ef3bb13eb14ec935b20c63c8ed7e11dcdc1ceff4949870b02d8043786d5ba47ef9c06ab8dffe4470661f391c97948cd14624ecb97c63281e1c
7
- data.tar.gz: 76b92da130d9a2e5c5af854c5ca566bfaa8fda97e35d0426bc381b59712ff9864246a96f2c0e3cf336062f86f220d99dd14bac5924a6e3062daf66c402cb6d26
6
+ metadata.gz: 72ab6acba13a562b4a4e1d85508abd8043e5a6a50c73ddeeae5f7158075b6964ebb45906e0e9d4c3b9c29bae01356c8b977d71a40c56c029be0745a2acf7d55e
7
+ data.tar.gz: f235f9d5dac99d38ee65386998b36046a4697d185903f165efbbdd348162340ef5822a663538329d037d9d67bd05a923d61a430f2344beb527e297a417827573
data/lib/attr_cached.rb CHANGED
@@ -22,6 +22,12 @@ class ActiveRecord::Base
22
22
  raise missing_id if id.nil?
23
23
  Rails.cache.write(key + id.to_s, value)
24
24
  end
25
+
26
+ # Define the method to delete the attribute from the cache
27
+ define_method "delete_#{attribute}" do
28
+ raise missing_id if id.nil?
29
+ Rails.cache.delete(key + id.to_s)
30
+ end
25
31
  end
26
32
  end
27
33
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attr_cached
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.1'
4
+ version: '1.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Swan