File Coverage

blib/lib/Bread/Board/SetterInjection.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


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