State_machine_ext is a project mainly written in Ruby, it's free.
state_machine extensions (state groups, find transitions)
= state_machine extensions state_machine_ext is an extension of the state_machine[https://github.com/pluginaweek/state_machine] gem.
== Install gem install state_machine_ext
== Usage This gem adds state groups functionality and method to find all possible transitions from a state. Below is an example of the features offered:
=== Class definition
class Order state_machine :initial => :not_selected do event :choose do transition :not_selected => :selected end event :add_to_basket do transition :selected => :in_basket end event :pay do transition :in_basket => :paid end event :to_send do transition :paid => :sent end
#initialize groups of the states
group :not_paid do
state :not_selected
state :selected
state :in_basket
end
group :in_progress do
state :paid, :sent
end
end
end
=== Using extensions
order = Order.new
order.state_all_transitions #=> [:sent, :paid, :in_basket, :selected]
order.state_all_transitions(:in_basket) #=> [:sent, :paid]
order.group(:not_paid).include?(:selected) #=> true
order.find_group(:paid) #=> [:in_progress]
== Credits
=== Project Team
Copyright (c) 2010 {Sphere Consulting Inc.}[http://www.sphereinc.com], released under the MIT license (see LICENSE).