Module: Tasker::StepHandler::AutomaticEventPublishing

Included in:
Base
Defined in:
lib/tasker/step_handler/base.rb

Overview

Automatic event publishing wrapper for step handlers

This module automatically publishes step lifecycle events around the execution of step handler methods, eliminating the need for developers to manually add event publishing code in their handlers.

Uses Ruby's prepend mechanism to wrap the handle method transparently.

Instance Method Summary collapse

Instance Method Details

#handle(task, sequence, step) ⇒ Object

Automatically publish events around step handler execution

This method wraps the original handle method and ensures that appropriate lifecycle events are published without requiring developers to add event publishing code manually.

⚠️ IMPORTANT: This method should NEVER be overridden by developers. Developers should implement the process() method instead.

Parameters:

Returns:

  • (Object)

    The result of processing the step



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/tasker/step_handler/base.rb', line 29

def handle(task, sequence, step)
  # Publish step started event automatically
  publish_step_started(step)

  # Fire the before_handle event for compatibility with existing code
  publish_step_before_handle(step)

  begin
    # Call the original handle method implemented by the framework
    result = super

    # Publish step completed event automatically
    publish_step_completed(step)

    result
  rescue StandardError => e
    # Publish step failed event automatically with error information
    publish_step_failed(step, error: e)

    # Re-raise the exception to preserve error handling behavior
    raise
  end
end