I needed a dirt simple state machine that was flexible enough to meet the needs of some very ‘edge’ requirements in a project I recently worked on. I found that most of the Ruby state machines out there were making too many assumptions for the level of flexibility I needed. This weekend I wrote a small gem called Bravery.
It’s only ~55 lines of Ruby and it:
- Tracks object state
- Handles user-defined callback / validation behavior when entering a state
- Absolutely nothing else (and that’s a good thing!)
Check it out on Github.