wmiirc-rumai

git clone git://oldgit.suckless.org/wmiirc-rumai/
Log | Files | Refs | README | LICENSE

commit d8ad242ef062de28f24830cf225f64b071a2a834
parent 910219e8a681539b3dc09aa70c8d206673ba6997
Author: Suraj N. Kurapati <sunaku@gmail.com>
Date:   Fri, 27 Apr 2007 09:56:24 -0700

add support for registration of multiple block handlers for the same key

Diffstat:
wmiirc | 9+++++++--
1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/wmiirc b/wmiirc @@ -31,11 +31,16 @@ begin # Miniature DSL to ease configuration. class Handler < Hash + # When a block is given, registers a handler for the given key. + # Otherwise, executes all registered handlers for the given key. def handle aKey, *aArgs, &aBlock if block_given? - self[aKey] = aBlock + (self[aKey] ||= []) << aBlock + elsif key? aKey - self[aKey].call(*aArgs) + self[aKey].each do |block| + block.call(*aArgs) + end end end end