NAME

Mojo::Loader - Loader

SYNOPSIS

use Mojo::Loader;

# Long
my @instances = Mojo::Loader->new
  ->namespace('Some::Namespace')
  ->search
  ->load
  ->base('Some::Module')
  ->build;

# Short
my $something = Mojo::Loader->load_build('Some::Namespace');

# Reload
Mojo::Loader->reload;

DESCRIPTION

Mojo::Loader is a class loader and plugin framework.

ATTRIBUTES

base

my $base = $loader->base;
$loader  = $loader->base('MyApp::Base');

modules

my $modules = $loader->modules;
$loader     = $loader->modules([qw/MyApp::Foo MyApp::Bar/]);

namespace

my $namespace = $loader->namespace;
$loader       = $loader->namespace('MyApp::Namespace');

METHODS

Mojo::Loader inherits all methods from Mojo::Base and implements the following new ones.

new

my $loader = Mojo::Loader->new;
my $loader = Mojo::Loader->new('MyApp::Namespace');

build

my $instances = $loader->build;
my $instances = $loader->build(qw/foo bar baz/);

load

$loader = $loader->load;

load_build

my $instance = Mojo::Loader->load_build('MyApp');
my $instance = $loader->load_build('MyApp');
my $instance = Mojo::Loader->load_build('MyApp', qw/some args/);
my $instance = $loader->load_build('MyApp', qw/some args/);

reload

Mojo::Loader->reload;
$loader = $loader->search;
$loader = $loader->search('MyApp::Namespace');