blib/lib/Kelp/Routes/Location.pm

filter: Statementstmt 88.2% 15 / 17 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 60.0% 3 / 5 Podpod 0.0% 0 / 1 totaltotal 74.0% 20 / 27 CC 3 SCAR 6.5
CC
3
Cov
81%
add
3.1
__ANON__
1.1
__ANON__
1.1
CRAP 1.9
« blib/lib/Kelp/Routes/Controller.pm ↑ Summary blib/lib/Kelp/Module/Logger.pm »
1 package Kelp::Routes::Location;
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 0 ▶attr 'router' => sub { croak 'router is required' };
Subroutine __ANON__: not called CC=1 SCAR=1.2
7 0 ▶attr 'parent' => sub { croak 'parent is required' };
Subroutine __ANON__: not called CC=1 SCAR=1.2
8  
9 sub add
10 6 ▶{
Subroutine add: called CC=3 SCAR=11.2
Pod undocumented
11 6 my ($self, $pattern, $descr, $parent_data) = @_;
12 6 my $parent = $self->parent;
13  
14 6 ▶ croak "Cannot chain 'add' calls because the parent route was not parsed correctly"
Branch: 1 branch
BranchTrueFalseTotal
unless $parent 0 6 6
15 unless $parent;
16  
17 # discard $parent_data from args
18 6 ▶ $parent_data = {
Branch: 1 branch
BranchTrueFalseTotal
$parent->has_name ? : 6 0 6
19 ($parent->has_name ? (name => $parent->name) : ()),
20 pattern => $parent->pattern,
21 };
22  
23 # parent is a bridge now (even if the add call fails)
24 6 $parent->bridge(1);
25 6 return $self->router->add($pattern, $descr, $parent_data);
26 }
27  
28 43 1;
29  
30 # internal only
31 # It's not a router reimplementation! It's just a facade for the add method of
32 # the router. Developers will interact with it without even knowing.
33  
« blib/lib/Kelp/Routes/Controller.pm ↑ Summary blib/lib/Kelp/Module/Logger.pm »