NAME
Bolts::Blueprint::Factory - Build an artifact by calling a class method on a class
VERSION
version 0.143171
SYNOPSIS
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', '_'),
);
DESCRIPTION
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.
ROLES
ATTRIBUTES
class
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.
method
This is the method to call on the "class". Defaults to "new".
METHODS
builder
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.
AUTHOR
Andrew Sterling Hanenkamp <hanenkamp@cpan.org>
COPYRIGHT AND LICENSE
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.