blib/lib/Kelp/Module.pm

filter: Statementstmt 96.9% 32 / 33 Branchbran 100% 6 / 6 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 88.8% 8 / 9 Podpod 66.6% 2 / 3 totaltotal 94.6% 53 / 56 CC 5 SCAR 9.6
CC
5
Cov
98%
register
5.0
build
2.0
BEGIN
1.0
CRAP 2.6
« blib/lib/Kelp/Module/Config.pm ↑ Summary blib/lib/Kelp/Response.pm »
1 package Kelp::Module;
2  
3 43 ▶use Kelp::Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 43 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 43 our @CARP_NOT = qw(Kelp);
7  
8 1 ▶attr -app => sub { die "app is required" };
Subroutine __ANON__: called CC=1 SCAR=0.0
9  
10 sub new
11 219 ▶{
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
12 219 my $self = shift->SUPER::new(@_);
13 219 $self->app;
14 218 return $self;
15 }
16  
17 # Override this to register items
18 sub build
19 0 ▶{
Subroutine build: not called CC=1 SCAR=6.9
Pod documented
20 0 my ($self, %args) = @_;
21 }
22  
23 sub register
24 264 ▶{
Subroutine register: called CC=5 SCAR=16.1
Pod documented
25 264 my ($self, %items) = @_;
26 264 ▶ while (my ($name, $item) = each(%items)) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %items) 381 247 628
27 43 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
28 43 ▶ no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 381 my $app = ref $self->app;
31 381 my $glob = "${app}::$name";
32  
33 # Manually check if the glob is being redefined
34 381 ▶ if (!$ENV{KELP_REDEFINE} && $self->app->can($name)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $ENV{"KELP_REDEFINE"} and $self->app->can($name)) 17 364 381
Condition100%3/3
not $ENV{"KELP_REDEFINE"} and $self->app->can($name)
!ll&&!rl&&r
14422017
MC/DC100%2/2
not $ENV{"KELP_REDEFINE"} and $self->app->can($name)
not $ENV{"KELP_REDEFINE"} $self->app->can($name)
Truth table100%3/3
not(A) and B
A= not $ENV{"KELP_REDEFINE"}B= $self->app->can($name)
ABresult
0X0
100
111
35 17 croak "Redefining of $glob not allowed";
36 }
37  
38 364 ▶ if (ref $item eq 'CODE') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $item eq 'CODE') { } 180 184 364
39 180 *{$glob} = $item;
40 }
41 else {
42 184 $self->app->{$name} = $item;
43 184 ▶ *{$glob} = sub { $_[0]->{$name} }
Subroutine __ANON__: called CC=1 SCAR=0.0
44 184 }
45 }
46 }
47  
48 43 1;
49  
50 __END__
« blib/lib/Kelp/Module/Config.pm ↑ Summary blib/lib/Kelp/Response.pm »