Method: Dynflow::World#trigger
- Defined in:
- lib/dynflow/world.rb
#trigger(action_class = nil, *args, &block) ⇒ TriggerResult
blocks until action_class is planned if no arguments given, the plan is expected to be returned by a block
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/dynflow/world.rb', line 177 def trigger(action_class = nil, *args, &block) if action_class.nil? raise 'Neither action_class nor a block given' if block.nil? execution_plan = block.call(self) else execution_plan = plan(action_class, *args) end planned = execution_plan.state == :planned if planned done = execute(execution_plan.id, Concurrent::Promises.resolvable_future) Triggered[execution_plan.id, done] else PlaningFailed[execution_plan.id, execution_plan.errors.first.exception] end end |