1package Bread::Board::SetterInjection; 2our $AUTHORITY = 'cpan:STEVAN'; 3# ABSTRACT: service instantiating objects via setter functions 4$Bread::Board::SetterInjection::VERSION = '0.37'; 5use Moose; 6 7use Bread::Board::Types; 8 9with 'Bread::Board::Service::WithConstructor', 10 'Bread::Board::Service::WithParameters', 11 'Bread::Board::Service::WithDependencies'; 12 13has '+class' => (required => 1); 14 15sub get { 16 my $self = shift; 17 my $constructor = $self->constructor_name; 18 my $o = $self->class->$constructor(); 19 $o->$_($self->param($_)) foreach $self->param; 20 return $o; 21} 22 23__PACKAGE__->meta->make_immutable; 24 25no Moose; 1; 26 27__END__ 28 29=pod 30 31=encoding UTF-8 32 33=head1 NAME 34 35Bread::Board::SetterInjection - service instantiating objects via setter functions 36 37=head1 VERSION 38 39version 0.37 40 41=head1 DESCRIPTION 42 43This L<service|Bread::Board::Service> class instantiates objects by 44calling C<new> on a class, then calling setters on the returned 45object. 46 47This class consumes L<Bread::Board::Service::WithClass>, 48L<Bread::Board::Service::WithParameters>, 49L<Bread::Board::Service::WithDependencies>. 50 51=head1 ATTRIBUTES 52 53=head2 C<class> 54 55Attribute provided by L<Bread::Board::Service::WithClass>. This 56service makes it a required attribute: you can't call a constructor if 57you don't have a class. 58 59=head1 METHODS 60 61=head2 C<get> 62 63Calls the C<new> method on the L</class> to get the object to return; 64then, for each of the L<service 65parameters|Bread::Board::Service/params>, calls a setter with the same 66name as the parameter, passing it the parameter's value. 67 68=head1 AUTHOR 69 70Stevan Little <stevan@iinteractive.com> 71 72=head1 BUGS 73 74Please report any bugs or feature requests on the bugtracker website 75https://github.com/stevan/BreadBoard/issues 76 77When submitting a bug or request, please include a test-file or a 78patch to an existing test-file that illustrates the bug or desired 79feature. 80 81=head1 COPYRIGHT AND LICENSE 82 83This software is copyright (c) 2019, 2017, 2016, 2015, 2014, 2013, 2011, 2009 by Infinity Interactive. 84 85This is free software; you can redistribute it and/or modify it under 86the same terms as the Perl 5 programming language system itself. 87 88=cut 89