state_machine
https://github.com/pluginaweek/state_machine
Ruby
Adds support for creating state machines for attributes on any Ruby class
StateMachine::MatcherHelpers#same
Represents a state that matches the original +from+ state. This is useful
for defining transitions which are loopbacks.
== Examples
class Vehicle
state_machine do
event :ignite
transition [:idling, :first_gear] => same
end
end
end
In the above example, +same+ will match whichever the from state is. In
the case of the +ignite+ event, it is essential the same as the following:
transition :parked => :parked, :first_gear => :first_gearEdit
git clone [email protected]:pluginaweek/state_machine.git
cd state_machine
open lib/state_machine/matcher_helpers.rb
Contribute
# Make a new branchgit checkout -b -your-name--update-docs-StateMachine--MatcherHelpers-same-for-pr
# Commit to gitgit add lib/state_machine/matcher_helpers.rbgit commit -m "better docs for StateMachine::MatcherHelpers#same"
# Open pull requestgem install hub # on a mac you can `brew install hub`
hub fork
git push <your name> -your-name--update-docs-StateMachine--MatcherHelpers-same-for-pr
hub pull-request
# Celebrate!