Board/BlockInjection.pm

filter: Statementstmt 100% 14 / 14 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 100% 17 / 17 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
get
1.0
BEGIN
1.0
CRAP 1.0
« Board/Service/Alias.pm ↑ Summary Board/ConstructorInjection.pm »
1 package Bread::Board::BlockInjection;
2 59 our $AUTHORITY = 'cpan:STEVAN';
3 # ABSTRACT: service instantiated via custom subroutine
4 59 $Bread::Board::BlockInjection::VERSION = '0.36';
5 59 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 59 with 'Bread::Board::Service::WithParameters',
8 'Bread::Board::Service::WithDependencies',
9 'Bread::Board::Service::WithClass';
10  
11 59 has 'block' => (
12 is => 'rw',
13 isa => 'CodeRef',
14 required => 1,
15 );
16  
17  
18 sub get {
19 53 ▶ my $self = shift;
Subroutine get: called CC=1 SCAR=0.0
20 53 $self->block->($self)
21 }
22  
23 59 __PACKAGE__->meta->make_immutable;
24  
25 59 ▶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::BlockInjection - service instantiated via custom subroutine
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 a coderef supplied in the L</block> attribute.
45  
46 This class consumes L<Bread::Board::Service::WithClass>,
47 L<Bread::Board::Service::WithParameters>,
48 L<Bread::Board::Service::WithDependencies>.
49  
50 =head1 ATTRIBUTES
51  
52 =head2 C<block>
53  
54 A coderef, required. Will be invoked as a method on the service
55 object, so it can call L<<< C<< $_[0]->params
56 >>|Bread::Board::Service/params >>> to access parameters and (resolved)
57 dependencies. It should return an instance of L</class>.
58  
59 =head2 C<class>
60  
61 Attribute provided by L<Bread::Board::Service::WithClass>; if it is
62 set, L</block> should return an instance of this class (and the class
63 will be already loaded, so there's no need to C<require> it).
64  
65 =head1 METHODS
66  
67 =head2 C<has_class>
68  
69 Predicate for L</class>. If the service does not declare a class, the
70 L</block> can of course return whatever it wants.
71  
72 =head2 C<get>
73  
74 Calls the L</block> as a method on the service, and returns whatever
75 that returned.
76  
77 =head1 AUTHOR
78  
79 Stevan Little <stevan@iinteractive.com>
80  
81 =head1 BUGS
82  
83 Please report any bugs or feature requests on the bugtracker website
84 https://github.com/stevan/BreadBoard/issues
85  
86 When submitting a bug or request, please include a test-file or a
87 patch to an existing test-file that illustrates the bug or desired
88 feature.
89  
90 =head1 COPYRIGHT AND LICENSE
91  
92 This software is copyright (c) 2017, 2016, 2015, 2014, 2013, 2011, 2009 by Infinity Interactive.
93  
94 This is free software; you can redistribute it and/or modify it under
95 the same terms as the Perl 5 programming language system itself.
96  
97 =cut
« Board/Service/Alias.pm ↑ Summary Board/ConstructorInjection.pm »