MooseX::AbstractFactory::Role - AbstractFactory behaviour as a Moose extension
version 0.004003
You shouldn't be using this on its own, but via MooseX::AbstractFactory
Role to implement an AbstractFactory as a Moose extension.
Returns an instance of the requested implementation.
use MooseX::AbstractFactory; my $imp = My::Factory->create( 'Implementation', { connection => 'Type1' }, );
Optional: it provides the methods defined in _roles().
This can be overridden by a factory class definition if required: for example
sub _validate_implementation_class { my $self = shift; return 1; # all implementation classes are valid :) }
By default, the factory figures out the class of the implementation requested by prepending the factory class itself, so for example
my $imp = My::Factory->new( implementation => 'Implementation')
will return an object of class My::Factory::Implementation.
This can be overridden in the factory class by redefining the _get_implementation_class() method, for example:
sub _get_implementation_class { my ($self, $class) = @_; return "My::ImplementationClasses::$class"; }
No bugs have been reported. Yet.
Please report any bugs or feature requests to mike@altrion.org, or via RT.
mike@altrion.org
Thanks to Matt Trout for some of the ideas for the code in _validate_implementation_class.
Please report any bugs or feature requests on the bugtracker website https://github.com/fleetfootmike/MX-AbstractFactory/issues
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
Mike Whitaker <mike@altrion.org>
Caleb Cushing <xenoterracide@gmail.com>
This software is copyright (c) 2014 by Mike Whitaker.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install MooseX::AbstractFactory, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MooseX::AbstractFactory
CPAN shell
perl -MCPAN -e shell install MooseX::AbstractFactory
For more information on module installation, please visit the detailed CPAN module installation guide.