Ha! You've reproduced my code almost exactly :)

I'd like to hear what other people have to say about this approach,
but I'm afraid that we're the only ones left still reading this
thread.
 
Dan

> module EventListener
>   def register_handler( event_name, &action )
>     @actions ||= {}
>     @actions[event_name] ||= []
>     @actions[event_name] << action
>   end
>   def handle_event( event_name )
>     if @actions[event_name]
>       @actions[event_name].each { |action| action[self] }
>     end
>   end
>   def method_missing( symbol, *args, &block )
>     if /^on_/.match( symbol )
>       self.register_handler( symbol.to_s.gsub(/^on_/, '').to_sym, *args ) &block
>     else
>       self.handle_event( symbol )
>     end
>   end
> end
> 
> class Button
>   include EventListener
> end
> 
> button = Button.new
> button.on_push do |b|
>   puts "Don't push my buttons!"
> end
> 
> button.push