NAME
Bolts::Blueprint::Built - Build an artifact by running a subroutine
VERSION
version 0.143170
SYNOPSIS
use Bolts;
# Using the usual sugar...
artifact thing => (
builder => sub {
my ($self, $bag, $name, @params) = @_;
return MyApp::Thing->new(@params);
},
);
# Or directly...
my $meta = Bolts::Bag->start_bag;
my $artifact = Bolts::Artifact->new(
name => 'thing',
blueprint => $meta->locator->acquire('blueprint', 'built', {
builder => sub {
my ($self, $bag, $name, @params) = @_;
return MyApp::Thing->new(@params);
},
}),
scope => $meta->locator->acquire('scope', '_'),
);
DESCRIPTION
This is a blueprint for constructing an artifact using a custom subroutine. This is handy for gluing anything to anything.
ROLES
ATTRIBUTES
builder
Required. This is the subroutine to execute to construct the artifact. The reader for this attribute is named the_builder
.
METHODS
builder
This executes the subroutine in the builder
attribute.
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.