Comment

Comment by kjqgqkejbfefn

Just look for state-machine (finite state automata) on github

https://github.com/search?q=state-machine&type=repositories

This is a very common pattern in Ruby to manage state. It's especially useful to guard entering impossible states with respect to business logic and figuring out what went wrong. Something along the lines of:

    Can't transition Command from 'ordered' to 'to-deliver': paid() == false
look at this gem https://github.com/pluginaweek/state_machine to get an idea of what features are possible

No comments yet

Be the first to share your thoughts.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton