Port of Ruby's StateJacket: create and manage states with their transitions