Bolts::Blueprint - Defines the interface implemented by blueprints
version 0.143171
package MyApp::Blueprint::Custom; use Moose; with 'Bolts::Blueprint'; has service_locator => ( is => 'ro', isa => 'MyApp::ServiceLocator', ); sub builder { my ($self, $bag, $name, @params) = @_; $self->service_locator($name, @params); }
A blueprint is a class for retrieving a fresh instance of a value or object on behalf of an artifact.
sub builder { my ($self, $bag, $name, @params) = @_; ... }
This method must be implemented to perform the actual object construction. The arguments passed are as follows:
$self
This is the invocant, the blueprint object itself.
$bag
This is the bag that contains the artifact being constructed. This is often referenced as an object giving context to the construction.
$name
This is the name of the artifact being constructed. This is also given for context.
@params
These are the parameters passed in during the pre-injection phase. This may be a list of parameters or hash or whatever the injectors say should be passed in.
my $artifact = $blueprint->get($bag, $name, @params);
This is basically a wrapper around the call to "builder".
my $is_implied = $blueprint->implied_scope;
Sometimes, the blueprint itself is inherently scoped. For example, a literal value is immutable and therefore saving the value to the scope would be a waste of time. Another example is a service locator that might manage it's own scope based on complex features of the application state. In those cases, you may override this method to return a true value to cause the artifact to skip saving to and checking the scope for this value and calling the blueprint every time.
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.