Skip to content

Commit

Permalink
Remove unnecessary proc to simplify code and improve performance a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
fractaledmind committed Dec 16, 2024
1 parent 02e15f2 commit 3a060e5
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions lib/acidic_job/workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,11 @@ def take_step(step_definition)

return next_step if @execution.entries.exists?(step: curr_step, action: :succeeded)

step_method = performable_step_for(step_definition)
rescued_error = nil
begin
@execution.record!(step: curr_step, action: :started, timestamp: Time.now)
result = AcidicJob.instrument(:perform_step, **step_definition) do
step_method.call
perform_step_for(step_definition)
end
case result
when REPEAT_STEP
Expand Down Expand Up @@ -167,17 +166,15 @@ def take_step(step_definition)
end
end

def performable_step_for(step_definition)
def perform_step_for(step_definition)
step_name = step_definition.fetch("does")
step_method = method(step_name)

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

wrapper = step_definition["transactional"] ? @execution.method(:with_lock) : NO_OP_WRAPPER

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

0 comments on commit 3a060e5

Please sign in to comment.