NAME

Bolts::Blueprint::Acquired - acquire an artifact via a path and locator

VERSION

version 0.143170

SYNOPSIS

use Bolts;

# Using the usual sugar... these all use acquired blueprints
artifact thing1; # acquired by attribute
artifact thing2 => (
    path => [ 'thing1' ],
);
artifact thing3 => (
    locator => $other_loc,
    path    => [ 'other', 'thing' ],
);

# Or for injection
artifact thing4 => (
    class => 'MyApp::Thing',
    parameters => {
        foo => dep('thing1'), # uses this blueprint
    },
);

# Or directly...
my $meta = Bolts::Bag->start_bag;

my $artifact = Bolts::Artifact->new(
    name      => 'thing',
    blueprint => $meta->locator->acquire('blueprint', 'acquired', {
        path    => [ 'myapp', 'settings', 'thing' ],
        locator => $other_loc,
    },
    scope     => $meta->locator->acquire('scope', singleton'),
);

DESCRIPTION

A blueprint for constructing the object by acquiring it from a Bolts::Role::Locator. This is handy for assembling complex bags in Bolts. It is also used as a convenient way of injecting dependencies into an artifact.

ROLES

ATTRIBUTES

locator

This is the Bolts::Role::Locator to acquire an artifact from. If none is given, the blueprint will use the bag the parent artifact is in as the locator.

path

This is the path within the locator to use for acquiring the artifact. If not given, the name of the parent artifact is used instead (which is primarily useful for injected dependencies and could lead to negative consquences, like looping forever, if used otherwise).

builder

This implements the actual acquisition from the "locator" (or the bag the parent artifact is in) and "path" (or the name of the parent artifact).

exists

Always returns true.

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.