Cataly...Context(3pm)
π Cataly...Context(3pm) π
okay so bestie, welcome to Catalyst::Component::InstancePerContext β the Perl module that gives you a brand new instance of a component on each and every request. yes, every single one. it's giving β¨fresh vibes onlyβ¨.
πΈ NAME πΈ
Catalyst::Component::InstancePerContext β returns a new instance a component on each request π¦
β¨ SYNOPSYS β¨
package MyComponent;
use Moose;
with 'Catalyst::Component::InstancePerContext';
sub build_per_context_instance{
my ($self, $c) = @_;
# ... do your thing here
return SomeModule->new(%args);
}
π REQUIRED METHODS π
so like, your consuming class has to implement this next one. no skipping, no shortcuts, it's mandatory bestie π
π§ build_per_context_instance
whatever this call hands back? that's literally what you get when you call $c->component('YourComponent'). that's the whole deal. that's the assignment π«Ά
π PROVIDED METHODS π
this role is gonna slide one extra method into your consuming class. consider it a gift π
π ACCEPT_CONTEXT
here's the tea β β if the context is not blessed, it just simply passes through the value of "build_per_context_instance". no drama, no fuss, straight through.
but if the context is blessed? then it goes looking in the "stash" for an instance of the requested component and returns that. and if that value isn't found? then whatever "build_per_context_instance" returned gets stored, and then returned. so it's cached in the stash for the rest of the request, iykyk π
the idea behind this whole behaviour is that a component can be built on a per-request basis β which is, like, literally what the name of this module is saying. it said it in the name. the name is the point. periodt π
π₯ SEE ALSO π₯
MooseMoose::RoleCatalyst::Component
π AUTHOR π
Guillermo Roditi (groditi) <groditi@cpan.org> β icon, legend, the moment π
π LICENSE π
you may distribute this code under the same terms as Perl itself. slay, go forth, distribute responsibly π
perl v5.34.0 πΈ 2022-06-09 β that's the version and the date bestie, and that's a wrap on Cataly...Context(3pm). mwah ππ¦β¨
π¦ where this page comes from
- debian bookworm: libcatalyst-component-instancepercontext-perl 0.001001-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libcatalyst-component-instancepercontext-perl 0.001001-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libcatalyst-component-instancepercontext-perl 0.001001-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libcatalyst-component-instancepercontext-perl 0.001001-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libcatalyst-component-instancepercontext-perl 0.001001-3 Β· 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