blib/lib/Dancer2/Core/Hook.pm

filter: Statementstmt 100% 25 / 25 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod n/a totaltotal 100% 36 / 36 CC 3 SCAR 3.7
CC
3
Cov
100%
__ANON__
2.0
__ANON__
2.0
BEGIN
1.0
CRAP 1.4
« /usr/local/bin/prove ↑ Summary blib/lib/Dancer2/Core/Response/Delayed.pm »
1 package Dancer2::Core::Hook;
2 # ABSTRACT: Manipulate hooks with Dancer2
3 187 $Dancer2::Core::Hook::VERSION = '2.2.1';
4 187 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 187 ▶use Dancer2::Core::Types;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 187 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 187 ▶use Sub::Util qw/ set_subname subname /;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 has name => (
10 is => 'rw',
11 isa => Str,
12 required => 1,
13 coerce => sub {
14 821 ▶ my ($hook_name) = @_;
Subroutine __ANON__: called CC=2 SCAR=6.9
15  
16 # XXX at the moment, we have a filer position named "before_template".
17 # this one is renamed "before_template_render", so we need to alias it.
18 # maybe we need to deprecate 'before_template' to enforce the use
19 # of 'hook before_template_render => sub {}' ?
20 821 ▶ $hook_name = 'before_template_render'
Branch: 1 branch
BranchTrueFalseTotal
if $hook_name eq "before_template" 5 816 821
21 if $hook_name eq 'before_template';
22 821 return $hook_name;
23 },
24 187 );
25  
26 has code => (
27 is => 'ro',
28 isa => CodeRef,
29 required => 1,
30 coerce => sub {
31 417 ▶ my ($hook) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
32 set_subname subname($hook) => sub {
33 826 ▶ my $res = eval { $hook->(@_) };
Subroutine __ANON__: called CC=2 SCAR=6.9
34 818 ▶ croak "Hook error: $@" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 20 798 818
35 798 return $res;
36 417 };
37 },
38 187 );
39  
40 187 1;
41  
42 __END__
« /usr/local/bin/prove ↑ Summary blib/lib/Dancer2/Core/Response/Delayed.pm »