Newcomen

Description A static content generator.
Newcomen > Perl Modules > Newcomen::Role::Frontend
Source

Index


NAME ^

Newcomen::Role::Frontent - Moose role for frontend components.

SYNOPSIS ^

# In the consuming class:

with 'Newcomen::Role::Frontend' => {
   'namespace' => 'Foo::Bar',
   'type'      => 'Foo::Bar::Backend',
};

# Get a backend instance:
my $backend = $self -> backend ($backend_name);

DESCRIPTION ^

This is a Moose role to enable a class to act as a frontend for several backends. Backends will be searched and instantiated automatically as soon as required (and as late as possible, but as soon as one backend is accessed, all are instantiated). All backends must have a constructor called new() (created automatically for Moose classes).

OPTIONS ^

There are two parameters for this role: namespace specifies the namespace to look for backends, e.g. in the SYNOPSIS example above backends must be put in the Foo::Bar namespace, Foo::Bar::Baz would be a valid example for a backend name. The second parameter type must match the backend class (or one of its superclasses). In the example, Foo::Bar::Baz must extend Foo::Bar::Backend. The module type itself will always be skipped when loading the backends.

INSTANCE METHODS ^

The following methods allow access to the backends. They will be available in the consuming class.

backend

my $backend = $self -> backend ($full_name);

Returns a backend instance. The parameter must be the full module name. This name is case sensitive. Returns undef if the backend does not exist.

backend_exists

if ($self -> backend_exists ($full_name)) {
   # do something...
}

Returns a true value if the backend (specified by its full case sensitive module name) exists.

backends

my @backends = $self -> backends ();

Returns a list containing the full module names of all available backends.

MISCELLANEOUS ^

This role uses a _build_backends() method as a builder. The consuming class must not use this name itself.

SEE ALSO ^

Moose, Newcomen::Config, Newcomen::Formatter, Newcomen::Renderer, Newcomen::Writer

VERSION ^

This is version 2014052501.

AUTHOR ^

Stefan Goebel - newcomen {at} subtype {dot} de

COPYRIGHT AND LICENSE ^

Copyright 2013-2014 Stefan Goebel.

This file is part of Newcomen.

Newcomen is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the license, or (at your option) any later version.

Newcomen is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Newcomen. If not, see <http://www.gnu.org/licenses/>.