Class: DevSuite::Workflow::Step::Conditional

Inherits:
Base show all
Defined in:
lib/dev_suite/workflow/step/conditional.rb

Instance Attribute Summary

Attributes inherited from Base

#name, #next_step

Instance Method Summary collapse

Methods inherited from Base

#next

Methods inherited from Utils::Construct::Component::Base

component_key

Constructor Details

#initialize(name:, condition:, &action) ⇒ Conditional

Returns a new instance of Conditional.



7
8
9
10
# File 'lib/dev_suite/workflow/step/conditional.rb', line 7

def initialize(name:, condition:, &action)
  super(name: name, &action)
  @condition = condition
end

Instance Method Details

#run(context) ⇒ Object

Only execute if the condition is met



13
14
15
16
17
18
19
# File 'lib/dev_suite/workflow/step/conditional.rb', line 13

def run(context)
  if @condition.call(context)
    super
  else
    Utils::Logger.log("Step: #{@name} - Skipped due to condition", level: :info)
  end
end