Rick Carlino

Personal blog of FarmBot co-founder Rick Carlino.

Covering Open Source news, history and best practices.

Stack Overflow Reddit Github Linkedin Twitter

[ 💬 Contact ] [ 👤 About ] [ 📰 Recent Reading ] [ ✉️ Subscribe ]

Bravery: My Micro State Machine Library for Ruby.

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.