state-machine-workflow

How do I create dynamic definitions for state machine based on user defined data in DB

柔情痞子 提交于 2020-01-01 17:09:14
问题 I am trying to write an application that will allow users to manage workflows using the State Machine gem but I am not sure how to proceed in allowing users to define their own state machines using the State Machine gem for ruby. In the dynamic definitions portion of the gem documentation it says that I should be able to do this by replacing code like this below with a data source. def transitions [ {:parked => :idling, :on => :ignite}, {:idling => :first_gear, :first_gear => :second_gear,

Complicated state transitions: best practices

徘徊边缘 提交于 2019-12-24 02:41:52
问题 I work with embedded stuff, and I have some software module that manages hardware. This module has state, and state transitions are complicated: depending on events, the module could go from state A to state B or probably to C . But, when it exits some state, it should perform some actions with the hardware, in order to keep it in correct state too. For rather simple modules, I just have a couple of functions like this: enum state_e { MY_STATE__A, MY_STATE__B, }; static enum state_e _cur

state_machine gem integration with rails 4

我们两清 提交于 2019-12-14 01:28:08
问题 I am facing a problem with usage of state_machine gem with my rails 4 app. A have a model which include a column call state as described in the provided rails tutorial http://gistflow.com/posts/679-state-machine-with-rails-basics but when I define my state_machine as follows: class Issue < ActiveRecord::Base validates :title, :description, presence: true has_many :notes state_machine :initial => :new do state :new, value: 0 state :analysed, value: 1 state :assigned, value: 2 state :inprogress