erector_cache 0.0.2 → 0.0.3

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 CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -27,7 +27,7 @@ module ErectorCache
27
27
  collection << if part.is_a?(Hash) && hash.keys.include?(p_prime)
28
28
  part[p_prime].call(hash[p_prime])
29
29
  else
30
- hash[p_prime.to_param]
30
+ hash[p_prime].to_param
31
31
  end
32
32
  end.join(":")
33
33
 
@@ -19,7 +19,21 @@ class Master
19
19
  end
20
20
 
21
21
  def to_param
22
- name
22
+ @name
23
+ end
24
+ end
25
+
26
+ class Weapon
27
+ def initialize(name)
28
+ @name = name
29
+ end
30
+
31
+ def name
32
+ @name
33
+ end
34
+
35
+ def to_param
36
+ @name
23
37
  end
24
38
  end
25
39
 
@@ -74,7 +88,7 @@ describe ErectorCache::Widget do
74
88
  @output.should_not include expected_cached_at_time
75
89
  end
76
90
 
77
- it "allows you to pass in an object as a key value to expire" do
91
+ it "expires based on cache key component that is a proc" do
78
92
  @he_man = Master.new("He-man")
79
93
  render_template do |controller|
80
94
  controller.render_widget Turtle, :name => "Leonardo", :weapon => "Katanas", :master => @splinter
@@ -91,6 +105,26 @@ describe ErectorCache::Widget do
91
105
  Lawnchair.redis.keys("*Splinter*").should be_blank
92
106
  Lawnchair.redis.keys("*He-man*").should_not be_blank
93
107
  end
108
+
109
+ it "expires based on regular object with to_param" do
110
+ @he_man = Master.new("He-man")
111
+ @shell = Weapon.new("Shell")
112
+
113
+ render_template do |controller|
114
+ controller.render_widget Turtle, :name => "Leonardo", :weapon => Weapon.new("Katanas"), :master => @splinter
115
+ end
116
+
117
+ render_template do |controller|
118
+ controller.render_widget Turtle, :name => "Myrtle", :weapon => @shell, :master => @he_man
119
+ end
120
+
121
+ Lawnchair.redis.keys("*Shell*").should_not be_blank
122
+ Lawnchair.redis.keys("*Katanas*").should_not be_blank
123
+ NinjaTurtle.expire!(:weapon => @shell)
124
+
125
+ Lawnchair.redis.keys("*Shell*").should be_blank
126
+ Lawnchair.redis.keys("*Katanas*").should_not be_blank
127
+ end
94
128
  end
95
129
 
96
130
  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: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Grockit