Bolts::Blueprint::Factory - Build an artifact by calling a class method on a class
version 0.143171
use Bolts; # Using the usual sugar... artifact thing1 => ( # construct via MyApp::Thing->new(...) class => 'MyApp::Thing', ); artifact thing2 => ( # construct via MyApp::Thing->load_standard_thing(...) class => 'MyApp::Thing', method => 'load_standard_thing', ); # Or directly... my $meta = Bolts::Bag->start_bag; my $artifact = Bolts::Artifact->new( name => 'thing', blueprint => $meta->locator->acquire('blueprint', 'factory', { class => 'MyApp::Thing', method => 'new', }), scope => $meta->locator->acquire('scope', '_'), );
Most applications of Bolts will make a great deal of use of this. It allows you to use a class name and a class method name to construct an object. This is the most straightforward way of constructing things and the way most easily inferred from.
Bolts::Blueprint
Required. This is the name of the class to call the "method" upon. This class will also be automatically loaded if it hasn't been loaded into the current Perl interpreter yet.
This is the method to call on the "class". Defaults to "new".
Loads the "class" if it has not yet been loaded. Then calls the "method" on it, passing through to the constructor whatever parameters were configured during pre-injection.
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.