A generic Ruby state machine pattern, with thread safety as a top priority.  Make your object a hegemon, in complete control of its states.