Bolts::Blueprint::BuiltInjector - An injector-oriented builder using a subroutine
version 0.143171
use Bolts; # Using the usual sugar... artifact thing => ( ... parameters => { thing => builder { my ($self, $bag, $name, %params) = @_; return MyApp::Thing->new(%params); }, }, ); # Or directly... my $meta = Bolts::Bag->start_bag; my $artifact = Bolts::Artifact->new( ... injectors => [ $meta->locator->acquire('injector', 'parameter_name', { key => 'thing', blueprint => $meta->locator->acquire('blueprint', 'built_injector', { builder => sub { my ($self, $bag, $name, %params) = @_; return MyApp::Thing->new(%params); }, }), }), ], );
This is a blueprint for using a subroutine to fill in an injected artifact dependency.
This differs from Bolts::Blueprint::Built in that it implements Bolts::Blueprint::Role::Injector, which tags this has only accepting named parameters to the builder method, which is required during injection.
Bolts::Blueprint::Role::Injector
Required. This is the subroutine to execute to construct the artifact. The reader for this attribute is named the_builder.
the_builder
This executes the subroutine in the builder attribute.
builder
Always returns true.
Andrew Sterling Hanenkamp <hanenkamp@cpan.org>
This software is copyright (c) 2014 by Qubling Software LLC.
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 Bolts, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Bolts
CPAN shell
perl -MCPAN -e shell install Bolts
For more information on module installation, please visit the detailed CPAN module installation guide.