<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -6,6 +6,7 @@ require 'hoe'
 Hoe.spec 'eventful' do |p|
   # self.rubyforge_name = 'eventfulx' # if different than 'eventful'
   p.developer('James Coglan', 'jcoglan@googlemail.com')
+  p.extra_deps = %w[methodphitamine]
 end
 
 # vim: syntax=ruby</diff>
      <filename>Rakefile</filename>
    </modified>
    <modified>
      <diff>@@ -1,16 +1,24 @@
 require 'observer'
+require 'rubygems'
+require 'methodphitamine'
 
 module Eventful
   VERSION = '0.9.0'
   
-  class Observer
+  class Observer &lt; Methodphitamine::It
     def initialize(&amp;block)
+      super()
       @block = block
     end
     
     def update(*args)
       @block.call(*args)
     end
+    
+    # Patch this back in after Methodphitamine removes it
+    def respond_to?(*args)
+      Object.instance_method(:respond_to?).bind(self).call(*args)
+    end
   end
   
   module ObservableWithBlocks
@@ -27,9 +35,12 @@ module Eventful
   include ObservableWithBlocks
   
   def on(event, &amp;block)
-    add_observer do |*args|
+    observer = add_observer do |*args|
       type, data = args.first, [self] + args[1..-1]
-      block.call(*data) if type == event
+      if type == event
+        block ||= observer.to_proc
+        block.call(*data)
+      end
     end
   end
   </diff>
      <filename>lib/eventful.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,10 +3,19 @@ require &quot;eventful&quot;
 
 class Foo
   include Eventful
+  attr_reader :count
+  
+  def initialize
+    @count = 0
+  end
+  
+  def bump!(x = 1)
+    @count += x
+  end
 end
 
 class TestEventful &lt; Test::Unit::TestCase
-  def test_sanity
+  def test_named_events
     ayes, noes = 0, 0
     f = Foo.new
     f.on(:aye) { |foo, x| ayes += x }
@@ -24,4 +33,15 @@ class TestEventful &lt; Test::Unit::TestCase
     assert_equal 1, ayes
     assert_equal 3, noes
   end
+  
+  def test_chaining
+    f = Foo.new
+    f.on(:aye).bump! 2
+    f.on(:noe).bump! -1
+    
+    2.times { f.fire(:aye) }
+    f.fire(:noe)
+    
+    assert_equal 3, f.count
+  end
 end</diff>
      <filename>test/test_eventful.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>d542a5db13eb87bd668ad15fed7d1e43380f3d8d</id>
    </parent>
  </parents>
  <author>
    <name>James Coglan</name>
    <email>jcoglan@googlemail.com</email>
  </author>
  <url>http://github.com/jcoglan/eventful/commit/e48e9bcae01492eac46fbc5843525941f9210642</url>
  <id>e48e9bcae01492eac46fbc5843525941f9210642</id>
  <committed-date>2009-06-18T03:57:12-07:00</committed-date>
  <authored-date>2009-06-18T03:57:12-07:00</authored-date>
  <message>Implement methodphitamine-based chaining for event handlers.</message>
  <tree>f8d3f7b9bc028108ac21aa5a9e6d1301bdda382f</tree>
  <committer>
    <name>James Coglan</name>
    <email>jcoglan@googlemail.com</email>
  </committer>
</commit>
