gocardless / statesman

A statesmanlike state machine library.
https://gocardless.com/blog/statesman/
MIT License
1.79k stars 163 forks source link

Allow the state_machine method to return nil. #536

Open woodhull opened 10 months ago

woodhull commented 10 months ago

In our product we have a model that has an optional state machine. The state_machine method returns nil for instances where no state_machine is appropriate / the state machine functionality is not relevant.

This method was causing an exception when the instance was reloaded. It's fixed with this safe navigation operator.