package Bread::Board::SetterInjection;
our $AUTHORITY = 'cpan:STEVAN';
# ABSTRACT: service instantiating objects via setter functions
$Bread::Board::SetterInjection::VERSION = '0.37';
use Moose;

use Bread::Board::Types;

with 'Bread::Board::Service::WithConstructor',

has '+class' => (required => 1);

sub get {
    my $self = shift;
    my $constructor = $self->constructor_name;
    my $o = $self->class->$constructor();
    $o->$_($self->param($_)) foreach $self->param;
    return $o;


no Moose; 1;



=encoding UTF-8

=head1 NAME

Bread::Board::SetterInjection - service instantiating objects via setter functions

=head1 VERSION

version 0.37


This L<service|Bread::Board::Service> class instantiates objects by
calling C<new> on a class, then calling setters on the returned

This class consumes L<Bread::Board::Service::WithClass>,


=head2 C<class>

Attribute provided by L<Bread::Board::Service::WithClass>. This
service makes it a required attribute: you can't call a constructor if
you don't have a class.

=head1 METHODS

=head2 C<get>

Calls the C<new> method on the L</class> to get the object to return;
then, for each of the L<service
parameters|Bread::Board::Service/params>, calls a setter with the same
name as the parameter, passing it the parameter's value.

=head1 AUTHOR

Stevan Little <>

=head1 BUGS

Please report any bugs or feature requests on the bugtracker website

When submitting a bug or request, please include a test-file or a
patch to an existing test-file that illustrates the bug or desired


This software is copyright (c) 2019, 2017, 2016, 2015, 2014, 2013, 2011, 2009 by Infinity Interactive.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.