Class: Fractor::Workflow::ExecutionHooks
- Inherits:
-
Object
- Object
- Fractor::Workflow::ExecutionHooks
- Defined in:
- lib/fractor/workflow/execution_hooks.rb
Overview
Manages lifecycle hooks for workflow execution. Allows registering callbacks for workflow/job lifecycle events.
Instance Method Summary collapse
-
#initialize ⇒ ExecutionHooks
constructor
A new instance of ExecutionHooks.
-
#register(event) {|Object| ... } ⇒ Object
Register a callback for a specific event.
-
#trigger(event, *args) ⇒ Object
Trigger all callbacks registered for an event.
Constructor Details
#initialize ⇒ ExecutionHooks
Returns a new instance of ExecutionHooks.
8 9 10 |
# File 'lib/fractor/workflow/execution_hooks.rb', line 8 def initialize @hooks = Hash.new { |h, k| h[k] = [] } end |
Instance Method Details
#register(event) {|Object| ... } ⇒ Object
Register a callback for a specific event.
21 22 23 |
# File 'lib/fractor/workflow/execution_hooks.rb', line 21 def register(event, &block) @hooks[event] << block end |
#trigger(event, *args) ⇒ Object
Trigger all callbacks registered for an event.
32 33 34 35 36 |
# File 'lib/fractor/workflow/execution_hooks.rb', line 32 def trigger(event, *args) @hooks[event].each do |hook| hook.call(*args) end end |