erector_cache 0.0.1 → 0.0.2
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.
- data/VERSION +1 -1
- data/lib/erector_cache/widget.rb +7 -4
- data/spec/erector_cache/widget_spec.rb +18 -0
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
data/lib/erector_cache/widget.rb
CHANGED
@@ -21,11 +21,14 @@ module ErectorCache
|
|
21
21
|
|
22
22
|
def expire!(hash={})
|
23
23
|
hash = Hash.new("*").merge(hash)
|
24
|
-
|
25
24
|
search_key = self.key_components.inject(["Lawnchair", self.to_s]) do |collection, part|
|
26
|
-
|
27
|
-
collection <<
|
28
|
-
collection << hash
|
25
|
+
p_prime = (part.is_a?(Hash) ? part.keys.first : part)
|
26
|
+
collection << p_prime
|
27
|
+
collection << if part.is_a?(Hash) && hash.keys.include?(p_prime)
|
28
|
+
part[p_prime].call(hash[p_prime])
|
29
|
+
else
|
30
|
+
hash[p_prime.to_param]
|
31
|
+
end
|
29
32
|
end.join(":")
|
30
33
|
|
31
34
|
LAWNCHAIR.redis.keys(search_key).split.each{|key| LAWNCHAIR.redis.del(key) }
|
@@ -73,6 +73,24 @@ describe ErectorCache::Widget do
|
|
73
73
|
end
|
74
74
|
@output.should_not include expected_cached_at_time
|
75
75
|
end
|
76
|
+
|
77
|
+
it "allows you to pass in an object as a key value to expire" do
|
78
|
+
@he_man = Master.new("He-man")
|
79
|
+
render_template do |controller|
|
80
|
+
controller.render_widget Turtle, :name => "Leonardo", :weapon => "Katanas", :master => @splinter
|
81
|
+
end
|
82
|
+
|
83
|
+
render_template do |controller|
|
84
|
+
controller.render_widget Turtle, :name => "Myrtle", :weapon => "Shell", :master => @he_man
|
85
|
+
end
|
86
|
+
|
87
|
+
Lawnchair.redis.keys("*Splinter*").should_not be_blank
|
88
|
+
Lawnchair.redis.keys("*He-man*").should_not be_blank
|
89
|
+
NinjaTurtle.expire!(:master => @splinter)
|
90
|
+
|
91
|
+
Lawnchair.redis.keys("*Splinter*").should be_blank
|
92
|
+
Lawnchair.redis.keys("*He-man*").should_not be_blank
|
93
|
+
end
|
76
94
|
end
|
77
95
|
|
78
96
|
describe ".cache_for" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: erector_cache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Grockit
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-09-
|
18
|
+
date: 2010-09-20 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|