NAME
Bolts::Inference::Moose - Inference engine for Moose classes
VERSION
version 0.143171
SYNOPSIS
package MyApp::Thing;
use Moose;
has id => ( is => 'ro' );
has name => ( is => 'ro' );
package MyApp::Settings;
use Bolts;
artifact thing => (
class => 'MyApp::Thing',
infer => 'options',
);
package MyApp;
my $settings = MyApp::Settings->new;
my $thing = $settings->acquire('thing', {
id => 1,
name => 'something',
}); # works!
DESCRIPTION
Performs inferrence for Moose object constructor injection on Bolts::Blueprint::Factory. That is, it is the way in which Bolts will automatically guess how to build your Moose objects, provided you construct them with Bolts::Blueprint::Factory (see the "SYNOPSIS" for an example).
This works by iterating through the attributes on the metaclass for the Moose object set on the "class" in Bolts::Blueprint::Factory of the blueprint. If the attribute has an init_arg
set (which all do by default to a name matching the attribute name), then the dependency will be passed to the constructor as a parameter. If the init_arg
is undefined, but a setter is provided (i.e., you use isa => 'rw'
or use writer => 'set_attr'
or accessor => 'attr'
when setting up the attribute), the setter will be used for that dependency instead. If neither a setter or an init_arg
is defined, then the attribute will be skipped for injection.
ROLES
METHODS
infer
This implements the inferrence described in "DESCRIPTION".
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.