« lib/Plack/Middleware/APISchema/ResponseValidator.pm
↑ Summary
lib/Plack/Middleware/APISchema/RequestValidator.pm »
| 1 | package APISchema::Generator::Router::Simple; | ||||||||||||
| 2 | 4 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 3 | 4 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | |||||||||||||
| 5 | 4 | ▶ | use Hash::Merge::Simple qw(merge); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 4 | ▶ | use Class::Load qw(load_class); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | 4 | ▶ | use Class::Accessor::Lite ( | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | 4 | new => 1, | |||||||||||
| 9 | ro => [qw(router_class)], | ||||||||||||
| 10 | 4 | ); | |||||||||||
| 11 | |||||||||||||
| 12 | 4 | ▶ | use constant ROUTER_CLASS => 'Router::Simple'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 13 | |||||||||||||
| 14 | 17 | ▶ | sub generate_router { | ||||||||||
|
Subroutine
generate_router: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 15 | 17 | my ($self, $schema) = @_; | |||||||||||
| 16 | |||||||||||||
| 17 | 17 | ▶ | my $router_class = $self->router_class // ROUTER_CLASS; | ||||||||||
|
Condition100%2/2
$self->router_class // "Router::Simple"
MC/DC100%1/1
$self->router_class // "Router::Simple"
$self->router_class
Truth table100%2/2
A
A= $self->router_class
| |||||||||||||
| 18 | 17 | my $router = load_class($router_class)->new; | |||||||||||
| 19 | |||||||||||||
| 20 | 17 | $self->inject_routes($schema, $router); | |||||||||||
| 21 | } | ||||||||||||
| 22 | |||||||||||||
| 23 | 18 | ▶ | sub inject_routes { | ||||||||||
|
Subroutine
inject_routes: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||
| 24 | 18 | my ($self, $schema, $router) = @_; | |||||||||||
| 25 | |||||||||||||
| 26 | 18 | my $router_class = ref $router; | |||||||||||
| 27 | |||||||||||||
| 28 | 18 | for my $route (@{$schema->get_routes}) { | |||||||||||
| 29 | 25 | ▶ | my $option = $route->option // {}; | ||||||||||
|
Condition100%2/2
$route->option // {}
MC/DC100%1/1
$route->option // {}
$route->option
Truth table100%2/2
A
A= $route->option
| |||||||||||||
| 30 | 25 | ▶ | $option = merge $option, $option->{$router_class} // {}; | ||||||||||
|
Condition50%1/2
$option->{$router_class} // {}
MC/DC0%0/1
$option->{$router_class} // {}
$option->{$router_class}
Truth table50%1/2
A
A= $option->{$router_class}
| |||||||||||||
| 31 | $router->connect($route->title, $route->route => $route->destination, { | ||||||||||||
| 32 | method => $route->method, | ||||||||||||
| 33 | 25 | map { $_ => $option->{$_} } qw(host on_match), | |||||||||||
| 34 | }); | ||||||||||||
| 35 | } | ||||||||||||
| 36 | |||||||||||||
| 37 | 18 | $router; | |||||||||||
| 38 | } | ||||||||||||
| 39 | |||||||||||||
| 40 | 4 | 1; | |||||||||||