NAME

Mojolicious::Plugin::Module::Loader - Automatically load mojolicious namespaces

SYNOPSIS

$app->plugin('Module::Loader' => {
  command_namespaces => ['MyApp::Command'],
  plugin_namespaces  => ['MyApp::Plugin']
});

# Or
$app->plugin('Module::Loader');
...
$app->add_command_namespace('Dynamically::Loaded::Module::Command');
$app->add_plugin_namespace('Dynamically::Loaded::Module::Plugin');

DESCRIPTION

This module simply adds two mojolicious helpers, "add_command_namespace" and "add_plugin_namespace", and calls these automatically at registration time on the contents of the command_namespaces and plugin_namespaces configuration parameters, respectively.

METHODS

Mojolicious::Plugin::Cron::Scheduler inherits all methods from Mojolicious::Plugin and implements the following new ones

register( \%config )

Register plugin in Mojolicious application. Accepts a HashRef of parameters with two supprted keys:

command_namespaces

ArrayRef of namespaces to automatically call "add_command_namespace" on

controller_namespaces

ArrayRef of namespaces to automatically call "add_controller_namespace" on

plugin_namespaces

ArrayRef of namespaces to automatically call "add_plugin_namespace" on

add_command_namespace( $str )

Adds the given namespace to the Mojolicious Commands namespaces array. Packages inheriting from Mojolicious::Command in these namespaces are loaded as runnable commands from the mojo entrypoint script.

add_controller_namespace( $str )

Adds the given namespace to the Mojolicious routes namespaces array.

add_plugin_namespace( $str )

Searches the given namespace for packages inheriting from Mojolicious::Plugin and loads them via https://metacpan.org/pod/Mojolicious#plugin

AUTHOR

Mark Tyrrell <mark@tyrrminal.dev>

LICENSE

Copyright (c) 2024 Mark Tyrrell

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.