AlterEgo is a Ruby implementation of the State pattern as described by the Gang of Four. It differs from other Ruby state machine libraries in that it focuses on providing polymorphic behavior based on object state. In effect, it makes it easy to give an object different “personalities” depending on the state it is in.
Sometimes you want a single object to behave differently depending on what state it’s in. For instance, a traffic light has a different color depending on whether it is informing people that they should stop, slow down, or proceed.
Or a user account object might behave differently depending on whether the account is or is not in the ???confirmed??