[LRUG] State Transitions Are People Too
Oliver Legg
ollylegg at gmail.com
Tue Jun 11 04:42:18 PDT 2013
Thanks to JB for his talk last night. The topic is something I've been thinking about for a while.
We developed the EFG[1] application for GDS, and it uses a similar approach for building a state machine. As the code is open-source, I thought the LRUG community might find it interesting to see some real world (read: "not perfect") examples.
Just a quick bit of background – nearly all of the state transitions in this application are coupled to forms, and collect data. So we modelled them as ActiveModel instances and then used a common module, LoanStateTransition[2], to handle the flipping of the state column on the Loan ActiveRecord model. An example of how this is used is in the LoanOffer presenter[3].
Personally I think this approach works well in this application, but having used some of the gems mentioned last might I think they can be a more appropriate solution for smaller or less complicated state machines.
Thanks again for the talk.
Cheers, Olly
[1]: https://github.com/alphagov/EFG
[2]: https://github.com/alphagov/EFG/blob/master/app/concerns/loan_state_transition.rb
[3]: https://github.com/alphagov/EFG/blob/master/app/presenters/loan_offer.rb
More information about the Chat
mailing list