NAME

Thunderhorse::Module - Base class for Thunderhorse modules

SYNOPSIS

package MyApp::Module::Custom;

use v5.40;
use Mooish::Base -standard;

extends 'Thunderhorse::Module';

sub build ($self)
{
	# Add a method to controllers
	$self->add_method(
		controller => custom_action => sub ($controller, @args) {
			# your custom logic here
			return $controller;
		}
	);

	# Add a hook
	$self->add_hook(
		error => sub ($controller, $ctx, $error) {
			# handle errors
		}
	);

	# Add middleware
	$self->add_middleware($middleware_instance);
}

DESCRIPTION

Thunderhorse::Module is the base class for creating reusable modules that extend application functionality. Modules are loaded via configuration and can perform actions like adding methods to controllers, registering hooks, and adding middleware to the application.

Modules are automatically loaded during application startup when configured in the modules section of application configuration. Each module receives its configuration hash as the "config" attribute.

To create a custom module, extend this class and implement the "build" in Gears::Component method. Use the provided methods ("add_method", "add_middleware", "add_hook") to extend application functionality.

INTERFACE

Inherits all interface from Gears::Component, and adds the interface documented below.

Attributes

config

Configuration hash reference containing module-specific configuration values. This is populated from the application's configuration file when the module is loaded.

Required in the constructor

Methods

add_method

Delegated to "add_method" in Thunderhorse::App.

add_middleware

Delegated to "add_middleware" in Thunderhorse::App.

add_hook

Delegated to "add_hook" in Thunderhorse::App.

SEE ALSO

Gears::Component