Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在ruby状态机中触发状态之间的中间转换_Ruby_State Machine_Transitions - Fatal编程技术网

在ruby状态机中触发状态之间的中间转换

在ruby状态机中触发状态之间的中间转换,ruby,state-machine,transitions,Ruby,State Machine,Transitions,我正在使用 我的代码是 event :set_running do transition any => :runnning end event :restart do transition :failed => :restarting end after_transition :failed => :restarting do |job,transition| job.set_running end after_transition :restarting =&g

我正在使用

我的代码是

event :set_running do
 transition any => :runnning
end

event :restart do
 transition :failed => :restarting
end

after_transition :failed => :restarting do |job,transition|
  job.set_running
end

after_transition :restarting => :running do |job,transition|
  job.restart_servers 
=begin 
 this takes some time. and i would like job state to be "restarting" while
 it's restarting servers. but it doesn't happen (i suppose because of transaction) 
 until after_transition :failed => :restarting callback is finished.
 so it actually doesnt happen at all because this callback triggers => :running transition
=end
end
换句话说,我想运行一次“重新启动”事件,并在它从:failed传输到:running时触发中介转换。 我可以用状态机来做吗?

现在可以禁用事务:

state_machine :initial => :parked, :use_transactions => false do