= Travis Build Status {}[http://travis-ci.org/danpersa/edge-state-machine] = Edge State Machine The gem is based on Rick Olson's code of ActiveModel::StateMachine, axed from ActiveModel in {this commit}[http://github.com/rails/rails/commit/db49c706b62e7ea2ab93f05399dbfddf5087ee0c]. And on Krzysiek HerĂ³d's gem, {Transitions}[https://github.com/netizer/transitions], which added Mongoid support. == Installation If you're using Rails + ActiveRecord + Bundler # in your Gemfile gem "edge-state-machine", :require => ["edge-state-machine", "active_record/edge-state-machine"] # in your AR models that will use the state machine include ::EdgeStateMachine include ActiveRecord::EdgeStateMachine state_machine do state :available # first one is initial state state :out_of_stock state :discontinue event :discontinue do transitions :to => :discontinue, :from => [:available, :out_of_stock], :on_transition => :do_discontinue end event :out_of_stock do transitions :to => :out_of_stock, :from => [:available, :discontinue] end event :available do transitions :to => :available, :from => [:out_of_stock], :on_transition => :send_alerts end end If you're using Rails + Mongoid + Bundler # in your Gemfile gem "edge-state-machine", :require => ["edge-state-machine", "mongoid/edge-state-machine"] # in your AR models that will use the state machine include ::EdgeStateMachine include Mongoid::EdgeStateMachine state_machine do state :available # first one is initial state state :out_of_stock state :discontinue event :discontinue do transitions :to => :discontinue, :from => [:available, :out_of_stock], :on_transition => :do_discontinue end event :out_of_stock do transitions :to => :out_of_stock, :from => [:available, :discontinue] end event :available do transitions :to => :available, :from => [:out_of_stock], :on_transition => :send_alerts end end