public
Fork of freels/acts_as_state_machine
Description: git mirror of acts_as_state_machine with some additions
Homepage: http://elitists.textdriven.com/svn/plugins/acts_as_state_machine/
Clone URL: git://github.com/sudothinker/acts_as_state_machine.git
name age message
file CHANGELOG Loading commit data...
file MIT-LICENSE Sun Jan 15 09:08:57 -0800 2006 git-svn-id: http://elitists.textdriven.com/svn/... [sbarron]
file README
file Rakefile Sun Jan 15 09:29:13 -0800 2006 git-svn-id: http://elitists.textdriven.com/svn/... [sbarron]
file TODO Fri Jan 20 12:25:05 -0800 2006 git-svn-id: http://elitists.textdriven.com/svn/... [sbarron]
file init.rb Fri Jul 14 07:50:09 -0700 2006 git-svn-id: http://elitists.textdriven.com/svn/... [sbarron]
directory lib/
directory test/
README
= Acts As State Machine

This act gives an Active Record model the ability to act as a finite state
machine (FSM).

Acquire via git at:

http://github.com/sudothinker/acts_as_state_machine.git

Original repository available via subversion at:

http://elitists.textdriven.com/svn/plugins/acts_as_state_machine/trunk

If prompted, use the user/pass anonymous/anonymous.

== Example

 class Order < ActiveRecord::Base
   acts_as_state_machine :initial => :opened

   state :opened
   state :closed, :enter => Proc.new {|o| Mailer.send_notice(o)}
   state :returned

   event :close do
     transitions :to => :closed, :from => :opened
   end

   event :return do
     transitions :to => :returned, :from => :closed, :on_transition => :email_user
   end
   
 protected
   def email_user
     Notifier.deliver_order_returned(self)
   end
 end

 o = Order.create
 o.close! # notice is sent by mailer
 o.return!