File Coverage

blib/lib/Bread/Board/BlockInjection.pm
Criterion Covered Total %
statement 6 6 100.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 8 8 100.0


line stmt bran cond sub pod time code
1             package Bread::Board::BlockInjection;
2             our $AUTHORITY = 'cpan:STEVAN';
3             # ABSTRACT: service instantiated via custom subroutine
4             $Bread::Board::BlockInjection::VERSION = '0.37';
5 57     57   329216 use Moose;
  57         542960  
  57         513  
6              
7             with 'Bread::Board::Service::WithParameters',
8             'Bread::Board::Service::WithDependencies',
9             'Bread::Board::Service::WithClass';
10              
11             has 'block' => (
12             is => 'rw',
13             isa => 'CodeRef',
14             required => 1,
15             );
16              
17              
18             sub get {
19             my $self = shift;
20             $self->block->($self)
21             }
22              
23             __PACKAGE__->meta->make_immutable;
24              
25 57     57   390445 no Moose; 1;
  57         180  
  57         348  
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.37
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) 2019, 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