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/);
my $exception = $loader->build;
my $exception = $loader->build(qw/foo bar baz/);

load

my $exception = $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/);
my $exception = Mojo::Loader->load_build('MyApp');
my $exception = $loader->load_build('MyApp');
my $exception = Mojo::Loader->load_build('MyApp', qw/some args/);
my $exception = $loader->load_build('MyApp', qw/some args/);

reload

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