| 1 | package WebAPI::DBIC::Router; | ||||||||||||
| 2 | 25 | $WebAPI::DBIC::Router::VERSION = '0.004002'; | |||||||||||
| 3 | |||||||||||||
| 4 | 25 | ▶ | use Moo; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | |||||||||||||
| 6 | 25 | ▶ | use Carp qw(croak); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | |||||||||||||
| 8 | 25 | ▶ | use Path::Router; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | 25 | ▶ | use Plack::App::Path::Router; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | |||||||||||||
| 11 | 25 | ▶ | use namespace::clean -except => [qw(meta)]; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 12 | 25 | ▶ | use MooX::StrictConstructor; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 13 | |||||||||||||
| 14 | |||||||||||||
| 15 | has router => ( | ||||||||||||
| 16 | is => 'ro', | ||||||||||||
| 17 | 25 | ▶ | default => sub { Path::Router->new }, | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 18 | 25 | handles => [ qw(match) ], | |||||||||||
| 19 | ); | ||||||||||||
| 20 | |||||||||||||
| 21 | |||||||||||||
| 22 | 223 | ▶ | sub add_route { | ||||||||||
|
Subroutine
add_route: called CC=5 SCAR=17.5
Pod
undocumented
| |||||||||||||
| 23 | 223 | my ($self, %args) = @_; | |||||||||||
| 24 | |||||||||||||
| 25 | 223 | my $path = delete $args{path}; | |||||||||||
| 26 | 223 | ▶ | my $validations = delete $args{validations} || {}; | ||||||||||
|
Condition50%1/2
delete $args{'validations'} || {}
MC/DC0%0/1
delete $args{'validations'} || {}
delete $args{'validations'}
Truth table50%1/2
A
A= delete $args{'validations'}
| |||||||||||||
| 27 | 223 | ▶ | my $defaults = delete $args{defaults} || {}; | ||||||||||
|
Condition50%1/2
delete $args{'defaults'} || {}
MC/DC0%0/1
delete $args{'defaults'} || {}
delete $args{'defaults'}
Truth table50%1/2
A
A= delete $args{'defaults'}
| |||||||||||||
| 28 | 223 | ▶ | my $target = delete $args{target} or croak "target not specified"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 29 | 0 | ▶ | croak "Unknown params (@{[ sort keys %args ]})" if %args; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 30 | |||||||||||||
| 31 | 223 | $self->router->add_route($path, | |||||||||||
| 32 | validations => $validations, | ||||||||||||
| 33 | defaults => $defaults, | ||||||||||||
| 34 | target => $target, | ||||||||||||
| 35 | ); | ||||||||||||
| 36 | } | ||||||||||||
| 37 | |||||||||||||
| 38 | |||||||||||||
| 39 | 25 | ▶ | sub to_psgi_app { | ||||||||||
|
Subroutine
to_psgi_app: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 40 | 25 | my $self = shift; | |||||||||||
| 41 | 25 | return Plack::App::Path::Router->new( router => $self->router )->to_app; # return Plack app | |||||||||||
| 42 | } | ||||||||||||
| 43 | |||||||||||||
| 44 | |||||||||||||
| 45 | 0 | ▶ | sub uri_for { # called by WebAPI::DBIC::Resource::Role::Router | ||||||||||
|
Subroutine
uri_for: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 46 | 0 | local $SIG{__DIE__}; # https://github.com/timbunce/WebAPI-DBIC/issues/22 | |||||||||||
| 47 | 0 | return shift->router->uri_for(@_); | |||||||||||
| 48 | } | ||||||||||||
| 49 | |||||||||||||
| 50 | |||||||||||||
| 51 | 25 | 1; | |||||||||||
| 52 | |||||||||||||
| 53 | __END__ | ||||||||||||