Cataly...ponent(3pm)
π Cataly...ponent(3pm) β CatalystX::InjectComponent π
okay bestie, welcome to a page from User Contributed Perl Documentation β¨ the title got squished to Cataly...ponent(3pm) by the terminal, but it's really CatalystX::InjectComponent and it's here to help π
πΈ NAME πΈ
CatalystX::InjectComponent β inject components into your Catalyst application π«Ά
β VERSION β
version 0.025 β yes, the number is literally that, don't @ me π
β¨ SYNOPSIS β¨
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 π¦
so what does this thing even do? CatalystX::InjectComponent will inject Controller, Model, and View components into your Catalyst application at setup (run)time. the way it pulls this off is iconic honestly: it creates a brand-new package on-the-fly, makes that package extend the component you gave it, and then lets Catalyst set up the new component (via ->setup_component) π
π So, how do I use this thing? π
you should inject your components when it's appropriate, typically after setup_compenents runs π«‘
if you're running the Moose version of Catalyst, then this technique right here is the move:
use Moose;
BEGIN { extends qw/Catalyst/ }
after 'setup_components' => sub {
my $class = shift;
CatalystX::InjectComponent->inject( into => $class, ... )
};
π₯ METHODS π₯
π
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, bestie, watch this:
->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 π
inspired by Catalyst::Plugin::AutoCRUD β the blueprint, the blueprint π
π AUTHOR π
Robert Krimen <robertkrimen@gmail.com> β the mastermind, periodt β¨
π COPYRIGHT AND LICENSE π
this software is copyright (c) 2012 by Robert Krimen.
this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. π«Ά
ok that's the whole page, no skips, no shortcuts π―
and a lil sign-off for the record: this was rendered by perl v5.34.0 and dated 2022-06-09 β iconic, timeless, we love her ππβ¨
π¦ where this page comes from
- debian bookworm: libcatalystx-injectcomponent-perl 0.025-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libcatalystx-injectcomponent-perl 0.025-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libcatalystx-injectcomponent-perl 0.025-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms