With the previous implementation of method_missing() in HookContext, it
was not possible to set the value of a local to nil, since that would be
assumed to mean "that local does not exist" and super would get called.

Now we use has_key? to check whether the local exists or not, and nil
will be returned normally from method_missing if that's the value of the
@__locals[name].

Signed-off-by: Adeodato Simó <[email protected]>
---
 lib/sup/hook.rb |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/lib/sup/hook.rb b/lib/sup/hook.rb
index 0a0a2f6..8a52a96 100644
--- a/lib/sup/hook.rb
+++ b/lib/sup/hook.rb
@@ -20,13 +20,15 @@ class HookManager
     attr_writer :__locals
 
     def method_missing m, *a
-      case @__locals[m]
-      when Proc
-        @__locals[m] = @__locals[m].call(*a) # only call the proc once
-      when nil
+      if not @__locals.has_key? m
         super
       else
-        @__locals[m]
+        case @__locals[m]
+        when Proc
+          @__locals[m] = @__locals[m].call(*a) # only call the proc once
+        else
+          @__locals[m]
+        end
       end
     end
 
-- 
1.6.3.3

_______________________________________________
sup-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/sup-talk

Reply via email to