Module: Axn::Core::Flow::Callbacks::ClassMethods
- Defined in:
- lib/axn/core/flow/callbacks.rb
Instance Method Summary collapse
-
#_dispatch_callbacks(event_type, action:, exception: nil) ⇒ Object
Internal dispatcher.
-
#on_error(handler = nil, &block) ⇒ Object
Handles both fail! and unhandled exceptions.
-
#on_exception(handler = nil, &block) ⇒ Object
ONLY raised exceptions (i.e. NOT fail!).
-
#on_failure(handler = nil, &block) ⇒ Object
ONLY raised on fail! (i.e. NOT unhandled exceptions).
-
#on_success(handler = nil, &block) ⇒ Object
Executes when the action completes successfully (after all after hooks complete successfully) Runs in child-first order (child handlers before parent handlers).
Instance Method Details
#_dispatch_callbacks(event_type, action:, exception: nil) ⇒ Object
Internal dispatcher
20 21 22 23 24 25 26 27 28 |
# File 'lib/axn/core/flow/callbacks.rb', line 20 def _dispatch_callbacks(event_type, action:, exception: nil) resolver = Axn::Core::Flow::Handlers::Resolvers::CallbackResolver.new( _callbacks_registry, event_type, action:, exception:, ) resolver.execute_callbacks end |
#on_error(handler = nil, &block) ⇒ Object
Handles both fail! and unhandled exceptions
37 |
# File 'lib/axn/core/flow/callbacks.rb', line 37 def on_error(handler = nil, **, &block) = _add_callback(:error, handler:, **, block:) |
#on_exception(handler = nil, &block) ⇒ Object
ONLY raised exceptions (i.e. NOT fail!).
31 |
# File 'lib/axn/core/flow/callbacks.rb', line 31 def on_exception(handler = nil, **, &block) = _add_callback(:exception, handler:, **, block:) |
#on_failure(handler = nil, &block) ⇒ Object
ONLY raised on fail! (i.e. NOT unhandled exceptions).
34 |
# File 'lib/axn/core/flow/callbacks.rb', line 34 def on_failure(handler = nil, **, &block) = _add_callback(:failure, handler:, **, block:) |
#on_success(handler = nil, &block) ⇒ Object
Executes when the action completes successfully (after all after hooks complete successfully) Runs in child-first order (child handlers before parent handlers)
41 |
# File 'lib/axn/core/flow/callbacks.rb', line 41 def on_success(handler = nil, **, &block) = _add_callback(:success, handler:, **, block:) |