<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -111,7 +111,7 @@ module Workflow
 
   class Specification
 
-    attr_accessor :states, :meta, :on_transition
+    attr_accessor :states, :meta, :on_transition, :before_transition, :after_transition
 
     def initialize(meta = {}, &amp;specification)
       @states = []
@@ -120,7 +120,7 @@ module Workflow
     end
 
     def to_instance(reconstitute_at = nil)
-      Instance.new(states, @on_transition, @meta, reconstitute_at)
+      Instance.new(states, @before_transition, @on_transition, @after_transition, @meta, reconstitute_at)
     end
 
     def blat(meta = {}, &amp;specification)
@@ -140,6 +140,14 @@ module Workflow
       @on_transition = proc
     end
 
+    def before_transition(&amp;proc)
+      @before_transition = proc
+    end
+
+    def after_transition(&amp;proc)
+      @after_transition = proc
+    end
+
     def event(name, args = {}, &amp;action)
       scoped_state.add_event Event.new(name, args[:transitions_to], (args[:meta] or {}), &amp;action)
     end
@@ -169,11 +177,12 @@ module Workflow
       end
     end
 
-    attr_accessor :states, :meta, :current_state, :on_transition, :context
+    attr_accessor :states, :meta, :current_state, :on_transition, :before_transition, :after_transition, :context
 
-    def initialize(states, on_transition, meta = {}, reconstitute_at = nil)
+    def initialize(states, before_transition, on_transition, after_transition, meta = {}, reconstitute_at = nil)
       Workflow.logger.debug &quot;Creating workflow instance&quot;
-      @states, @on_transition, @meta = states, on_transition, meta
+      @states, @meta = states, on_transition, meta
+      @before_transition, @on_transition, @after_transition = before_transition, on_transition, after_transition
       @context = self
       if reconstitute_at.nil?
         transition(nil, states.first, nil)
@@ -284,8 +293,10 @@ module Workflow
           false
         end
       else
-        run_on_transition(current_state, states(event.transitions_to), name, *args)
+        # run_on_transition(current_state, states(event.transitions_to), name, *args)
+        run_before_transition(current_state, states(event.transitions_to), name, *args)
         transition(current_state, states(event.transitions_to), name, *args)
+        run_after_transition(current_state, states(event.transitions_to), name, *args)
         return_value
       end
     end
@@ -318,10 +329,18 @@ module Workflow
       run_on_entry(to, from, name, *args)
     end
 
+    def run_before_transition(from, to, event, *args)
+      context.instance_exec(from.name, to.name, event, *args, &amp;before_transition) if before_transition
+    end
+
     def run_on_transition(from, to, event, *args)
       context.instance_exec(from.name, to.name, event, *args, &amp;on_transition) if on_transition
     end
 
+    def run_after_transition(from, to, event, *args)
+      context.instance_exec(from.name, to.name, event, *args, &amp;after_transition) if after_transition
+    end
+
     def run_action(action, *args)
       context.instance_exec(*args, &amp;action) if action
     end</diff>
      <filename>lib/workflow.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>0fc381d7198b9a2e55a27bbfd15c9356e6fd0d1f</id>
    </parent>
  </parents>
  <author>
    <name>Ryan Allen</name>
    <email>ryan@yeahnah.org</email>
  </author>
  <url>http://github.com/ryan-allen/workflow/commit/a0cf0f37c6206cbdb628893ffcd70d1a66445684</url>
  <id>a0cf0f37c6206cbdb628893ffcd70d1a66445684</id>
  <committed-date>2009-04-29T22:34:30-07:00</committed-date>
  <authored-date>2009-04-29T22:34:30-07:00</authored-date>
  <message>introduce before_transition and after_transition, so we can go after_transition { save! }, when using it with active record</message>
  <tree>11d23bc6751b80a506376f3770709546e7cd4a9d</tree>
  <committer>
    <name>Ryan Allen</name>
    <email>ryan@yeahnah.org</email>
  </committer>
</commit>
