eris::role::pluggable - Implements the plumbing for an object to support plugins
version 0.006
Implements helpers around creating plugins to make things easier to plug.
package eris::schemas; use Moo; with qw(eris::role::pluggable); sub _build_namespace { 'eris::schema' } sub find { my ($self,$log) = @_; foreach my $p ($self->plugins) { return $p->name if $p->match_log($log); } } package main; my $schemas = eris::schemas->new( search_path => [ qw( my::app::schema ) ], disabled => [ qw( eris::schema::syslog ) ], config => { access => { index_name => 'www-%Y.%m.%d' } } );
Primary namespace for the plugins for this object. No default provided, you must implement _build_namespace in your plugin.
_build_namespace
An ArrayRef of additional namespaces or directories to search to load our plugins. Default is an empty array.
An ArrayRef of explicitly disallowed package namespaces to prevent loading. Default is an empty array.
An instance of Module::Pluggable::Object to use to locate plugins.
You shouldn't need this considering the options available, but always nice to have the option to override it with _build_loader.
_build_loader
This plugin class expects the loader's plugin() call to return a list of class names, not instantiated objects.
A HashRef of configs for passing along to our plugins. The init arg for this parameter is 'config' to simplify instantiation and config files.
Special considerations are taken when processing the hash. The namespace and search_path are automatically prepended to all keys to allow pretty config. This means I can pass a config like this:
namespace
search_path
my $schema = eris::schemas->new( search_path => [qw(my::app::schema)], config => { syslog => { enabled => 0 }, eris::schema::syslog => { enabled => 1 }, access => { enabled => 0 }, }, );
This will expand the config to:
config => { my::app::schema::access => { enabled => 0 }, eris::schema::access => { enabled => 0 }, my::app::schema::syslog => { enabled => 0 }, eris::schema::syslog => { enabled => 1 }, },
The explicit config for 'eris::schema::syslog' is retained.
The priority sorted list of plugin objects found by the loader. The plugins call expects the loader function to return a list of class names, not objects.
plugins
loader
eris::role::plugin, eris::schemas, eris::log::contexts, eris::log::decoders
Brad Lhotsky <brad@divisionbyzero.net>
This software is Copyright (c) 2015 by Brad Lhotsky.
This is free software, licensed under:
The (three-clause) BSD License
To install eris, copy and paste the appropriate command in to your terminal.
cpanm
cpanm eris
CPAN shell
perl -MCPAN -e shell install eris
For more information on module installation, please visit the detailed CPAN module installation guide.