Class: GenevaDrive::StepDefinition Private
- Inherits:
-
Object
- Object
- GenevaDrive::StepDefinition
- Defined in:
- lib/geneva_drive/step_definition.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Metadata about a step definition in a workflow. Holds the step name, callable (block or method name), wait time, skip conditions, and exception handling configuration.
Constant Summary collapse
- EXCEPTION_HANDLERS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Valid exception handler values
%i[pause! cancel! reattempt! skip!].freeze
- NOT_SET =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Sentinel value to distinguish "on_exception not provided" from "on_exception: :pause!"
Object.new.freeze
- VALID_SKIP_CONDITION_TYPES =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Valid types for skip conditions
[Symbol, Proc, TrueClass, FalseClass, NilClass].freeze
Instance Attribute Summary collapse
-
#after_step ⇒ String?
readonly
private
Name of step this should be placed after.
-
#before_step ⇒ String?
readonly
private
Name of step this should be placed before.
-
#block_location ⇒ Array<String, Integer>?
readonly
private
Source location of the step block [path, lineno].
-
#call_location ⇒ Array<String, Integer>?
readonly
private
Source location where step was called [path, lineno].
-
#callable ⇒ Proc, Symbol
readonly
private
The callable to execute (block or method name).
-
#exception_policy ⇒ GenevaDrive::ExceptionPolicy, GenevaDrive::CombinedExceptionPolicy
readonly
private
Exception handling policy.
-
#name ⇒ String
readonly
private
The step name.
-
#skip_condition ⇒ Proc, ...
readonly
private
Condition for skipping this step.
-
#wait ⇒ ActiveSupport::Duration?
readonly
private
Wait time before executing this step.
Instance Method Summary collapse
-
#execute_in_context(workflow) ⇒ Object
private
Executes the step callable in the context of the workflow.
-
#initialize(name:, callable:, call_location: nil, block_location: nil, **options) ⇒ StepDefinition
constructor
private
Creates a new step definition.
-
#max_reattempts ⇒ Integer?
private
Returns the max_reattempts from the exception policy.
-
#on_exception ⇒ Symbol?
private
Returns the action symbol from the exception policy.
-
#should_skip?(workflow) ⇒ Boolean
private
Evaluates whether this step should be skipped for the given workflow.
Constructor Details
#initialize(name:, callable:, call_location: nil, block_location: nil, **options) ⇒ StepDefinition
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Creates a new step definition.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/geneva_drive/step_definition.rb', line 62 def initialize(name:, callable:, call_location: nil, block_location: nil, **) @name = name.to_s @callable = callable @call_location = call_location @block_location = block_location @wait = [:wait] @skip_if_option = [:skip_if] @if_option = [:if] @skip_condition = @skip_if_option || @if_option @on_exception_raw = .fetch(:on_exception, NOT_SET) @max_reattempts_raw = [:max_reattempts] @max_reattempts_explicitly_set = .key?(:max_reattempts) @terminal_action_raw = [:terminal_action] @before_step = [:before_step]&.to_s @after_step = [:after_step]&.to_s validate! @exception_policy = build_exception_policy end |
Instance Attribute Details
#after_step ⇒ String? (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns name of step this should be placed after.
37 38 39 |
# File 'lib/geneva_drive/step_definition.rb', line 37 def after_step @after_step end |
#before_step ⇒ String? (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns name of step this should be placed before.
34 35 36 |
# File 'lib/geneva_drive/step_definition.rb', line 34 def before_step @before_step end |
#block_location ⇒ Array<String, Integer>? (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns source location of the step block [path, lineno].
43 44 45 |
# File 'lib/geneva_drive/step_definition.rb', line 43 def block_location @block_location end |
#call_location ⇒ Array<String, Integer>? (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns source location where step was called [path, lineno].
40 41 42 |
# File 'lib/geneva_drive/step_definition.rb', line 40 def call_location @call_location end |
#callable ⇒ Proc, Symbol (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the callable to execute (block or method name).
22 23 24 |
# File 'lib/geneva_drive/step_definition.rb', line 22 def callable @callable end |
#exception_policy ⇒ GenevaDrive::ExceptionPolicy, GenevaDrive::CombinedExceptionPolicy (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns exception handling policy.
31 32 33 |
# File 'lib/geneva_drive/step_definition.rb', line 31 def exception_policy @exception_policy end |
#name ⇒ String (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the step name.
19 20 21 |
# File 'lib/geneva_drive/step_definition.rb', line 19 def name @name end |
#skip_condition ⇒ Proc, ... (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns condition for skipping this step.
28 29 30 |
# File 'lib/geneva_drive/step_definition.rb', line 28 def skip_condition @skip_condition end |
#wait ⇒ ActiveSupport::Duration? (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns wait time before executing this step.
25 26 27 |
# File 'lib/geneva_drive/step_definition.rb', line 25 def wait @wait end |
Instance Method Details
#execute_in_context(workflow) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Executes the step callable in the context of the workflow.
113 114 115 116 117 118 119 |
# File 'lib/geneva_drive/step_definition.rb', line 113 def execute_in_context(workflow) if @callable.is_a?(Symbol) workflow.send(@callable) else workflow.instance_exec(&@callable) end end |
#max_reattempts ⇒ Integer?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the max_reattempts from the exception policy. Provided for backward compatibility with code that reads step_def.max_reattempts.
96 97 98 |
# File 'lib/geneva_drive/step_definition.rb', line 96 def max_reattempts @exception_policy&.max_reattempts end |
#on_exception ⇒ Symbol?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the action symbol from the exception policy. Provided for backward compatibility with code that reads step_def.on_exception.
86 87 88 89 90 |
# File 'lib/geneva_drive/step_definition.rb', line 86 def on_exception return nil unless @exception_policy return nil if @exception_policy.is_a?(GenevaDrive::CombinedExceptionPolicy) @exception_policy.action end |
#should_skip?(workflow) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Evaluates whether this step should be skipped for the given workflow.
104 105 106 107 |
# File 'lib/geneva_drive/step_definition.rb', line 104 def should_skip?(workflow) return false unless @skip_condition evaluate_condition(@skip_condition, workflow) end |