<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -108,6 +108,38 @@ Based on the work of Ryan Allen and Scott Barron
 
 Licensed under MIT license, see the MIT-LICENSE file.
 
+
+== New in the version 0.3.0
+
+Intermixing of transition graph definition (states, transitions)
+on the one side and implementation of the actions on the other side
+for a bigger state machine can introduce clutter.
+
+To reduce this clutter it is now possible to use state entry- and 
+exit- hooks defined through a naming convention. For example, if there
+is a state :pending, then instead of using a
+block:
+
+    state :pending do
+      on_entry do
+        # your implementation here
+      end
+    end
+
+you can hook in by defining method 
+
+def on_pending_exit(new_state, event, *args)
+  # your implementation here
+end
+
+anywhere in your class. You can also use a simpler function signature
+like `def on_pending_exit(*args)` if your are not interested in arguments -
+`def on_pending_exit()` with an empty list would not work.
+
+If both a function with a name according to naming convention and the 
+on_entry/on_exit block are given, then only on_entry/on_exit block is used.
+
+
 = Original readme
 
 Disclaimer: my fork is not 100% API compatible to the original library by Ryan.</diff>
      <filename>README.rdoc</filename>
    </modified>
    <modified>
      <diff>@@ -11,7 +11,7 @@ Rake::TestTask.new do |t|
   t.pattern = 'test/*_test.rb'
 end
 
-PKG_VERSION = &quot;0.2.0&quot;
+PKG_VERSION = &quot;0.3.0&quot;
 PKG_FILES = FileList[
   'MIT-LICENSE',
   'README.rdoc',</diff>
      <filename>Rakefile</filename>
    </modified>
    <modified>
      <diff>@@ -200,11 +200,23 @@ module Workflow
     end
 
     def run_on_entry(state, prior_state, triggering_event, *args)     
-      instance_exec(prior_state.name, triggering_event, *args, &amp;state.on_entry) if state.on_entry
+      if state.on_entry
+        instance_exec(prior_state.name, triggering_event, *args, &amp;state.on_entry) 
+      else
+        hook_name = &quot;on_#{state}_entry&quot;
+        self.send hook_name, prior_state, triggering_event, *args if self.respond_to? hook_name
+      end
     end
 
     def run_on_exit(state, new_state, triggering_event, *args)
-      instance_exec(new_state.name, triggering_event, *args, &amp;state.on_exit) if state and state.on_exit
+      if state
+        if state.on_exit
+          instance_exec(new_state.name, triggering_event, *args, &amp;state.on_exit)
+        else
+          hook_name = &quot;on_#{state}_exit&quot;
+          self.send hook_name, new_state, triggering_event, *args if self.respond_to? hook_name
+        end
+      end
     end
 
     # load_workflow_state and persist_workflow_state</diff>
      <filename>lib/workflow.rb</filename>
    </modified>
    <modified>
      <diff>@@ -250,5 +250,55 @@ class MainTest &lt; Test::Unit::TestCase
       Problem.new.solve!
     end
   end
+
+  # Intermixing of transition graph definition (states, transitions)
+  # on the one side and implementation of the actions on the other side
+  # for a bigger state machine can introduce clutter.
+  # 
+  # To reduce this clutter it is now possible to use state entry- and 
+  # exit- hooks defined through a naming convention. For example, if there
+  # is a state :pending, then you can hook in by defining method 
+  # `def on_pending_exit(new_state, event, *args)` instead of using a
+  # block:
+  #
+  #     state :pending do
+  #       on_entry do
+  #         # your implementation here
+  #       end
+  #     end
+  #
+  # If both a function with a name according to naming convention and the 
+  # on_entry/on_exit block are given, then only on_entry/on_exit block is used.
+  test 'on_entry and on_exit hooks in separate methods' do 
+    c = Class.new
+    c.class_eval do
+      include Workflow
+      attr_reader :history
+      def initialize
+        @history = []
+      end
+      workflow do
+        state :new do
+          event :next, :transitions_to =&gt; :next_state
+        end
+        state :next_state
+      end
+
+      def on_next_state_entry(prior_state, event, *args)
+        @history &lt;&lt; &quot;on_next_state_entry #{event} #{prior_state} -&gt;&quot;
+      end
+
+      def on_new_exit(new_state, event, *args)
+        @history &lt;&lt; &quot;on_new_exit #{event} -&gt; #{new_state}&quot;
+      end
+    end
+
+    o = c.new
+    assert_equal 'new', o.current_state.to_s
+    assert_equal [], o.history
+    o.next!
+    assert_equal ['on_new_exit next -&gt; next_state', 'on_next_state_entry next new -&gt;'], o.history
+
+  end 
 end
 </diff>
      <filename>test/main_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>cf01839c364bcbc2d9fbc1c5305469b2a1a60a4c</id>
    </parent>
  </parents>
  <author>
    <name>Vladimir Dobriakov</name>
    <email>vladimir@geekq.net</email>
  </author>
  <url>http://github.com/geekq/workflow/commit/9159c38b0515e76bba34d675a5f4db6baedff989</url>
  <id>9159c38b0515e76bba34d675a5f4db6baedff989</id>
  <committed-date>2009-08-10T04:40:46-07:00</committed-date>
  <authored-date>2009-08-10T04:40:46-07:00</authored-date>
  <message>New state entry- and exit- hooks</message>
  <tree>547cd527218f807c2d3c3faa15ed7ca124ed8d04</tree>
  <committer>
    <name>Vladimir Dobriakov</name>
    <email>vladimir@geekq.net</email>
  </committer>
</commit>
