Class: GenevaDrive::StepCollection Private
- Inherits:
-
Object
- Object
- GenevaDrive::StepCollection
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/geneva_drive/step_collection.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.
Manages an ordered collection of step definitions for a workflow. Handles step ordering based on before_step/after_step positioning and provides methods for navigating between steps.
Instance Method Summary collapse
-
#[](index) ⇒ StepDefinition?
Returns the step at the given index.
-
#at(position) ⇒ StepDefinition?
private
Finds a step by position (0-indexed).
-
#each {|StepDefinition| ... } ⇒ Enumerator
Iterates over steps in order.
-
#empty? ⇒ Boolean
Checks if the collection is empty.
-
#first ⇒ StepDefinition?
Returns the first step in the workflow.
-
#initialize(step_definitions) ⇒ StepCollection
constructor
private
Creates a new step collection from an array of step definitions.
-
#key?(name) ⇒ Boolean
private
Checks if a step exists with the given name.
-
#last ⇒ StepDefinition?
Returns the last step in the workflow.
-
#named(name) ⇒ StepDefinition?
private
Finds a step by name.
-
#next_after(current_name) ⇒ StepDefinition?
private
Returns the next step after the given step name.
-
#previous_before(current_name) ⇒ StepDefinition?
private
Returns the step before the given step name in the ordered sequence.
-
#size ⇒ Integer
(also: #length)
Returns the number of steps.
Constructor Details
#initialize(step_definitions) ⇒ StepCollection
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 collection from an array of step definitions.
46 47 48 49 |
# File 'lib/geneva_drive/step_collection.rb', line 46 def initialize(step_definitions) @step_definitions = step_definitions @ordered_steps = nil end |
Instance Method Details
#[](index) ⇒ StepDefinition?
Returns the step at the given index.
40 |
# File 'lib/geneva_drive/step_collection.rb', line 40 def_delegators :ordered_steps, :each, :size, :first, :last, :empty?, :[], :index, :find_index |
#at(position) ⇒ 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.
Finds a step by position (0-indexed).
64 65 66 |
# File 'lib/geneva_drive/step_collection.rb', line 64 def at(position) ordered_steps[position] end |
#each {|StepDefinition| ... } ⇒ Enumerator
Iterates over steps in order.
|
|
# File 'lib/geneva_drive/step_collection.rb', line 14
|
#empty? ⇒ Boolean
Checks if the collection is empty.
|
|
# File 'lib/geneva_drive/step_collection.rb', line 31
|
#first ⇒ StepDefinition?
Returns the first step in the workflow.
|
|
# File 'lib/geneva_drive/step_collection.rb', line 23
|
#key?(name) ⇒ 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.
Checks if a step exists with the given name. Does not trigger ordering computation.
99 100 101 102 |
# File 'lib/geneva_drive/step_collection.rb', line 99 def key?(name) name_str = name.to_s @step_definitions.any? { |step| step.name == name_str } end |
#last ⇒ StepDefinition?
Returns the last step in the workflow.
|
|
# File 'lib/geneva_drive/step_collection.rb', line 27
|
#named(name) ⇒ 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.
Finds a step by name.
55 56 57 58 |
# File 'lib/geneva_drive/step_collection.rb', line 55 def named(name) name_str = name.to_s find { |step| step.name == name_str } end |
#next_after(current_name) ⇒ 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.
Returns the next step after the given step name.
72 73 74 75 76 77 78 79 |
# File 'lib/geneva_drive/step_collection.rb', line 72 def next_after(current_name) return first if current_name.nil? current_index = ordered_steps.index { |s| s.name == current_name.to_s } return nil unless current_index self[current_index + 1] end |
#previous_before(current_name) ⇒ 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.
Returns the step before the given step name in the ordered sequence.
85 86 87 88 89 90 91 92 |
# File 'lib/geneva_drive/step_collection.rb', line 85 def previous_before(current_name) return nil if current_name.nil? current_index = find_index { |s| s.name == current_name.to_s } return nil unless current_index && current_index > 0 self[current_index - 1] end |
#size ⇒ Integer Also known as: length
Returns the number of steps.
|
|
# File 'lib/geneva_drive/step_collection.rb', line 19
|