From: dato@net.com.org.es (Adeodato Simó)
Subject: [sup-talk] [PATCH] HookContext::method_missing(): allow locals to be nil
Date: Thu, 30 Jul 2009 17:57:16 +0200 [thread overview]
Message-ID: <b6ff832e5f1872bda03e7846260165e8571c6dae.1248969435.git.dato@net.com.org.es> (raw)
In-Reply-To: <20090730155656.GA20442@chistera.yi.org>
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? <dato at net.com.org.es>
---
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
next prev parent reply other threads:[~2009-07-30 15:57 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-10 15:00 [sup-talk] [PATCH] mime-decode hook: provide a "charset" variable with the attachment charset Adeodato Simó
2009-07-23 9:35 ` Adeodato Simó
2009-07-27 16:51 ` William Morgan
2009-07-30 15:56 ` Adeodato Simó
2009-07-30 15:57 ` Adeodato Simó [this message]
2009-08-19 21:22 ` Adeodato Simó
2009-08-22 18:15 ` William Morgan
2009-08-22 19:16 ` Adeodato Simó
2009-08-23 17:34 ` William Morgan
2009-09-13 23:17 ` Adeodato Simó
2009-09-26 18:12 ` William Morgan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b6ff832e5f1872bda03e7846260165e8571c6dae.1248969435.git.dato@net.com.org.es \
--to=dato@net.com.org.es \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox