Rick Carlino

Personal blog of Rick Carlino, senior software engineer at Qualia Labs, co-founder of Fox.Build Makerspace. Former co-founder of FarmBot.

Stack Overflow Reddit Linkedin Github Stack Overflow RSS

Bravery: My Micro State Machine Library for Ruby.

This is an archived article! The content may be out of date or irrelevant.

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.

If you enjoyed this article, please consider sharing it on sites like Hacker News or Lobsters.