I am currently working on a software system that implements dynamic workflows. Dynamic in a sense that every workflow is created by the customer admin or super admin for particular organization. In other words its a multi-tenant application. So, formerly the dynamic workflow was being maintained via different tables and maintaining transition relationship between the state’s events. However, The way we were implementing the dynamic state transition was quite tricky and alot of mess. Then I heard there is a few gems to implement finite state machine ( Workflow ). After analyzing their features and our requirements found out that they do not support dynamics out of the box however could be hacked to support the dynamics.
Implementing Dynamic workflow using workflow gem
Among various gems I picked up the gem workflow. It was okay with static workflows but it was tricky to make it dynamic. So, after leveraging hooks available in ActiveRecord and little bit of meta-programming in Ruby I succeeded to add dynamics to the workflow. Now user / CSA created workflows could transit from on state to another using various states.