perma_cache 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -43,6 +43,9 @@ module PermaCache
43
43
  module ClassMethods
44
44
  def perma_cache(method_name, options = {})
45
45
  class_eval do
46
+
47
+ was_rebuilt_inst_var = "@#{method_name}_was_rebuilt"
48
+
46
49
  define_method "#{method_name}_base_key" do
47
50
  key = []
48
51
  key << "perma_cache"
@@ -76,6 +79,7 @@ module PermaCache
76
79
  end
77
80
 
78
81
  define_method "#{method_name}!" do
82
+ instance_variable_set(was_rebuilt_inst_var , true)
79
83
  send("#{method_name}_without_perma_cache").tap do |result|
80
84
  PermaCache.cache.write(send("#{method_name}_perma_cache_key"), result, :expires_in => options[:expires_in])
81
85
  end
@@ -85,8 +89,6 @@ module PermaCache
85
89
  PermaCache.cache.read(send("#{method_name}_perma_cache_key"))
86
90
  end
87
91
 
88
- was_rebuilt_inst_var = "@#{method_name}_was_rebuilt"
89
-
90
92
  define_method "#{method_name}_with_perma_cache" do
91
93
  instance_variable_set(was_rebuilt_inst_var , false)
92
94
 
@@ -1,3 +1,3 @@
1
1
  module PermaCache
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -129,6 +129,7 @@ class PermaCacheTest < Test::Unit::TestCase
129
129
  PermaCache.cache = cache_obj
130
130
  obj.expects(:sleep).with(1).once
131
131
  assert_equal 1, obj.method1!
132
+ assert obj.method1_was_rebuilt?
132
133
  end
133
134
  end
134
135
  context "version option" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: perma_cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-02-04 00:00:00.000000000 Z
12
+ date: 2014-02-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails