Board/SetterInjection.pm

filter: Statementstmt 100% 20 / 20 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 100% 24 / 24 SCAR 6.9
CC
2
Cov
100%
get
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.0
« Board/Service/WithClass.pm ↑ Summary Board/BlockInjection.pm »
1 package Bread::Board::SetterInjection;
2 57 our $AUTHORITY = 'cpan:STEVAN';
3 # ABSTRACT: service instantiating objects via setter functions
4 57 $Bread::Board::SetterInjection::VERSION = '0.35';
5 57 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 57 ▶use Bread::Board::Types;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 57 with 'Bread::Board::Service::WithConstructor',
10 'Bread::Board::Service::WithParameters',
11 'Bread::Board::Service::WithDependencies';
12  
13 57 has '+class' => (required => 1);
14  
15 sub get {
16 10 ▶ my $self = shift;
Subroutine get: called CC=2 SCAR=6.9
17 10 my $constructor = $self->constructor_name;
18 10 my $o = $self->class->$constructor();
19 10 $o->$_($self->param($_)) foreach $self->param;
20 10 return $o;
21 }
22  
23 57 __PACKAGE__->meta->make_immutable;
24  
25 57 ▶no Moose; 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
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.35
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
« Board/Service/WithClass.pm ↑ Summary Board/BlockInjection.pm »