NAME
Mojo::Loader - Loader
SYNOPSIS
use Mojo::Loader;
# Find modules in a namespace
my $loader = Mojo::Loader->new;
for my $module (@{$loader->search('Some::Namespace')}) {
  # Load them safely
  my $e = $loader->load($module);
  warn qq{Loading "$module" failed: $e} and next if ref $e;
  # And extract files from the DATA section
  say $loader->data($module, 'some_file.txt');
}DESCRIPTION
Mojo::Loader is a class loader and plugin framework.
METHODS
Mojo::Loader inherits all methods from Mojo::Base and implements the following new ones.
data
my $all   = $loader->data('Foo::Bar');
my $index = $loader->data('Foo::Bar', 'index.html');Extract embedded file from the DATA section of a class, all files will be cached once they have been accessed for the first time.
say for keys %{$loader->data('Foo::Bar')};is_binary
my $bool = $loader->is_binary('Foo::Bar', 'test.png');Check if embedded file from the DATA section of a class was Base64 encoded.
load
my $e = $loader->load('Foo::Bar');Load a class and catch exceptions. Note that classes are checked for a new method to see if they are already loaded.
if (my $e = $loader->load('Foo::Bar')) {
  die ref $e ? "Exception: $e" : 'Not found!';
}search
my $modules = $loader->search('MyApp::Namespace');Search for modules in a namespace non-recursively.