Caleb Cushing > MooseX-AbstractFactory-0.004002 > MooseX::AbstractFactory::Role

Download:
MooseX-AbstractFactory-0.004002.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 0.004002   Source   Latest Release: MooseX-AbstractFactory-0.004003

NAME ^

MooseX::AbstractFactory::Role - AbstractFactory behaviour as a Moose extension

VERSION ^

version 0.004002

SYNOPSIS ^

You shouldn't be using this on its own, but via MooseX::AbstractFactory

DESCRIPTION ^

Role to implement an AbstractFactory as a Moose extension.

METHODS ^

create()

Returns an instance of the requested implementation.

        use MooseX::AbstractFactory;

        my $imp = My::Factory->create(
                'Implementation',
                { connection => 'Type1' },
        );

_validate_implementation_class()

Checks that the implementation class exists (via Class::Load::load_class() ) to be used, and (optionally) that 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 :)
        }

_get_implementation_class()

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";
        }

BUGS AND LIMITATIONS ^

No bugs have been reported. Yet.

Please report any bugs or feature requests to mike@altrion.org, or via RT.

ACKNOWLEDGMENTS ^

Thanks to Matt Trout for some of the ideas for the code in _validate_implementation_class.

BUGS ^

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.

AUTHORS ^

COPYRIGHT AND LICENSE ^

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.

syntax highlighting: