Skip to content

Commit

Permalink
Using step wrapping plugins when performing a step
Browse files Browse the repository at this point in the history
  • Loading branch information
fractaledmind committed Dec 16, 2024
1 parent 2c18bc7 commit 969f55f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/acidic_job/workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

module AcidicJob
module Workflow
NO_OP_WRAPPER = proc { |&block| block.call }
REPEAT_STEP = :REPEAT_STEP
HALT_STEP = :HALT_STEP
private_constant :NO_OP_WRAPPER, :REPEAT_STEP, :HALT_STEP
private_constant :REPEAT_STEP, :HALT_STEP

attr_reader :execution, :ctx

Expand Down Expand Up @@ -173,9 +172,11 @@ def perform_step_for(step_definition)

raise InvalidMethodError.new(step_name) unless step_method.arity.zero?

wrapper = step_definition["transactional"] ? @execution.method(:with_lock) : NO_OP_WRAPPER
plugin_pipeline_callable = plugins.reverse.reduce(step_method) do |callable, plugin|
proc { plugin.wrap(step_definition) { callable.call } }
end

catch(:repeat) { wrapper.call { step_method.call } }
catch(:repeat) { plugin_pipeline_callable.call }
rescue NameError
raise UndefinedMethodError.new(step_name)
end
Expand Down

0 comments on commit 969f55f

Please sign in to comment.