Module: Protege::HookMixin
- Included in:
- Hook
- Defined in:
- lib/protege/extensions/hook_mixin.rb
Overview
Contract mixin for hooks — the surface host apps use to declare reactions to engine lifecycle
events. A concrete hook subclasses Protege::Hook (which includes this module) and declares
handlers with the class-level on DSL, naming the event classes it cares about; each handler block
receives an instance of that Protege::Event subclass.
This module is declaration only. on merely records the block in the class's subscriptions
data, so a Zeitwerk reload just rebuilds that data. Activation — subscribing to the event bus and
running handlers — is a separate concern owned by Protege::Subscribers::HookDispatcher, which
reads this contract (+subscriptions+, stateful?) off each hook class when an event fires.
Handler blocks run (by the dispatcher) via instance_exec on a hook instance, so instance helper
methods — and, for stateful hooks, instance variables across a run — are available inside them.
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.included(base) ⇒ void
Extend the includer with
ClassMethodsso the +on+/+stateful+ DSL becomes available.
Class Method Details
.included(base) ⇒ void
This method returns an undefined value.
Extend the includer with ClassMethods so the +on+/+stateful+ DSL becomes available.
36 37 38 |
# File 'lib/protege/extensions/hook_mixin.rb', line 36 def self.included(base) base.extend(ClassMethods) end |