Class: Protege::Generators::HookGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Protege::Generators::HookGenerator
- Includes:
- ExtensionNaming
- Defined in:
- lib/generators/protege/hook/hook_generator.rb
Overview
Scaffolds a Protege hook — an event subscriber that reacts to the agent's run lifecycle — into the
host app's hooks directory (+config.hooks_path+, default app/hooks). A hook subclasses
Protege::Hook and declares on(SomeEvent) { |event| ... } handlers; the engine wires them onto
the event bus at boot (auto-discovered, no manual registration). Handlers run isolated, so an
error in one can never break inference.
The Hook suffix is applied for you.
Instance Method Summary collapse
-
#create_hook ⇒ void
Render the hook scaffold into
config.hooks_path.
Instance Method Details
#create_hook ⇒ void
This method returns an undefined value.
Render the hook scaffold into config.hooks_path.
28 29 30 |
# File 'lib/generators/protege/hook/hook_generator.rb', line 28 def create_hook template 'hook.rb.tt', File.join(Protege.configuration.hooks_path, "#{extension_file_name('Hook')}.rb") end |