CatalystX::InjectComponent - Inject components into your Catalyst application


CatalystX-InjectComponent documentation  | view source Contained in the CatalystX-InjectComponent distribution.

Index


NAME

Top

CatalystX::InjectComponent - Inject components into your Catalyst application

VERSION

Top

Version 0.024

SYNOPSIS

Top

    package My::App;

    use Catalyst::Runtime '5.80';

    use Moose;
    BEGIN { extends qw/Catalyst/ }

    ...

    after 'setup_components' => sub {
        my $class = shift;
        CatalystX::InjectComponent->inject( into => $class, component => 'MyModel' );
        if ( $class->config->{ ... ) {
            CatalystX::InjectComponent->inject( into => $class, component => 'MyRootV2', as => 'Controller::Root' );
        }
        else {
            CatalystX::InjectComponent->inject( into => $class, component => 'MyRootV1', as => 'Root' ); # Controller:: will be automatically prefixed
        }
    };

DESCRIPTION

Top

CatalystX::InjectComponent will inject Controller, Model, and View components into your Catalyst application at setup (run)time. It does this by creating a new package on-the-fly, having that package extend the given component, and then having Catalyst setup the new component (via ->setup_component)

So, how do I use this thing?

Top

You should inject your components when appropiate, typically after setup_compenents runs

If you're using the Moose version of Catalyst, then you can use the following technique:

    use Moose;
    BEGIN { extends qw/Catalyst/ }

    after 'setup_components' => sub {
        my $class = shift;

        CatalystX::InjectComponent->inject( into => $class, ... )
    };

METHODS

Top

CatalystX::InjectComponent->inject( ... )

    into        The Catalyst package to inject into (e.g. My::App)
    component   The component package to inject
    as          An optional moniker to use as the package name for the derived component 

For example:

    ->inject( into => My::App, component => Other::App::Controller::Apple )

        The above will create 'My::App::Controller::Other::App::Controller::Apple'

    ->inject( into => My::App, component => Other::App::Controller::Apple, as => Apple )

        The above will create 'My::App::Controller::Apple'

ACKNOWLEDGEMENTS

Top

Inspired by Catalyst::Plugin::AutoCRUD

AUTHOR

Top

Robert Krimen, <rkrimen at cpan.org>

BUGS

Top

Please report any bugs or feature requests to bug-catalystx-injectcomponent at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CatalystX-InjectComponent. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

Top

You can find documentation for this module with the perldoc command.

    perldoc CatalystX::InjectComponent




You can also look for information at:

* RT: CPAN's request tracker

http://rt.cpan.org/NoAuth/Bugs.html?Dist=CatalystX-InjectComponent

* AnnoCPAN: Annotated CPAN documentation

http://annocpan.org/dist/CatalystX-InjectComponent

* CPAN Ratings

http://cpanratings.perl.org/d/CatalystX-InjectComponent

* Search CPAN

http://search.cpan.org/dist/CatalystX-InjectComponent/

ACKNOWLEDGEMENTS

Top

COPYRIGHT & LICENSE

Top


CatalystX-InjectComponent documentation  | view source Contained in the CatalystX-InjectComponent distribution.