| 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
| |||||||||||
| 15 | unless $parent; | ||||||||||
| 16 | |||||||||||
| 17 | # discard $parent_data from args | ||||||||||
| 18 | 6 | ▶ | $parent_data = { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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 | |||||||||||