Class: Servactory::Actions::Tools::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/servactory/actions/tools/runner.rb

Overview

Executes service actions within stages.

## Purpose

Orchestrates the execution of service actions, handling stage wrappers, rollbacks, and conditional execution (only_if/only_unless). Provides the core execution engine for Servactory services.

## Usage

“‘ruby Runner.run!(context, collection_of_stages) “`

## Integration

Called by Servactory::Context::Callable to execute all actions defined in a service. Works with Stages::Collection and Actions::Collection.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context, collection_of_stages) ⇒ Runner

Creates a new runner instance.

Parameters:

  • context (Object)

    The service context with inputs/internals/outputs

  • collection_of_stages (Stages::Collection)

    Collection of stages to execute



38
39
40
41
# File 'lib/servactory/actions/tools/runner.rb', line 38

def initialize(context, collection_of_stages)
  @context = context
  @collection_of_stages = collection_of_stages
end

Class Method Details

.run!void

This method returns an undefined value.

Runs the service actions.

Parameters:

  • context (Object)

    The service context

  • collection_of_stages (Stages::Collection)

    The stages to execute



30
31
32
# File 'lib/servactory/actions/tools/runner.rb', line 30

def self.run!(...)
  new(...).run!
end

Instance Method Details

#run!void

This method returns an undefined value.

Executes all stages in position order.

Falls back to calling the service’s ‘call` method if no stages defined.



48
49
50
51
52
53
54
# File 'lib/servactory/actions/tools/runner.rb', line 48

def run!
  return use_call if @collection_of_stages.empty?

  @collection_of_stages.sorted_by_position.each do |stage|
    call_stage(stage)
  end
end