Slick/RouteManager.pm

filter: Statementstmt 100% 34 / 34 Branchbran 75.0% 6 / 8 Conditioncond 50.0% 3 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 1 totaltotal 83.6% 51 / 61 CC 9 SCAR 14.1
CC
9
Cov
90%
put
7.2
BUILD
3.1
BEGIN
1.0
CRAP 4.1
« Slick/RouteMap.pm ↑ Summary Slick/CacheExecutor/Memcached.pm »
1 package Slick::RouteManager;
2  
3 1 ▶use 5.036;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use Moo::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use Types::Standard qw(Str);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Slick::Events qw(EVENTS);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Slick::Methods qw(METHODS);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 has base => (
12 is => 'ro',
13 isa => Str,
14 default => ''
15 );
16  
17 has handlers => (
18 is => 'rw',
19 2 ▶ default => sub { return Slick::RouteMap->new; }
Subroutine __ANON__: called CC=1 SCAR=0.0
20 1 );
21  
22 1 foreach my $meth ( @{ METHODS() } ) {
23 Slick::Util::monkey_patch(
24 __PACKAGE__,
25 10 ▶ $meth => sub {
Subroutine put: called CC=7 SCAR=19.7
26 10 my ( $self, $route, $callback, $events ) = @_;
27  
28 10 ▶ $route = '/' . $route
Branch: 1 branch
BranchTrueFalseTotal
if $route ne "" and rindex($route, "/", 0) != 0 0 10 10
Condition33%1/3
$route ne "" and rindex($route, "/", 0) != 0
!ll&&!rl&&r
0100
MC/DC0%0/2
$route ne "" and rindex($route, "/", 0) != 0
$route ne "" rindex($route, "/", 0) != 0
Truth table33%1/3
A and B
A= $route ne ""B= rindex($route, "/", 0) != 0
ABresult
0X0
100
111
29 if ( $route ne '' ) && ( rindex( $route, '/', 0 ) != 0 );
30  
31 10 ▶ $route = $self->base . $route if $self->base;
Branch: 1 branch
BranchTrueFalseTotal
if $self->base 1 9 10
32  
33 10 my $route_object = Slick::Route->new(
34 callback => $callback,
35 route => $route
36 );
37  
38 10 ▶ if ($events) {
Branch: 1 branch
BranchTrueFalseTotal
if ($events) 2 8 10
39 2 foreach my $event ( EVENTS->@* ) {
40 $route_object->on( $event, $_ )
41 4 for ( @{ $events->{$event} } );
42 }
43 }
44  
45 10 $self->handlers->add( $route_object, $meth );
46  
47 10 return $route_object;
48 }
49 7 );
50 }
51  
52 2 ▶sub BUILD {
Subroutine BUILD: called CC=3 SCAR=11.4
Pod undocumented
53 2 my $self = shift;
54  
55 2 ▶ $self->{base} = '/' . $self->base
Branch: 1 branch
BranchTrueFalseTotal
if $self->base ne "" and rindex($self->base, "/", 0) != 0 0 2 2
Condition66%2/3
$self->base ne "" and rindex($self->base, "/", 0) != 0
!ll&&!rl&&r
110
MC/DC0%0/2
$self->base ne "" and rindex($self->base, "/", 0) != 0
$self->base ne "" rindex($self->base, "/", 0) != 0
Truth table66%2/3
A and B
A= $self->base ne ""B= rindex($self->base, "/", 0) != 0
ABresult
0X0
100
111
56 if ( $self->base ne '' ) && ( rindex( $self->base, '/', 0 ) != 0 );
57  
58 2 return $self;
59 }
60  
61 1 1;
62  
63 =encoding utf8
64  
65 =head1 NAME
66  
67 Slick::RouteManager
68  
69 =head1 SYNOPSIS
70  
71 A L<Moo::Role> that allows the managing of routes via a L<Slick::RouteMap> and HTTP methods.
72  
73 =over 2
74  
75 =item * L<Slick>
76  
77 =item * L<Slick::Router>
78  
79 =item * L<Slick::Context>
80  
81 =item * L<Slick::Database>
82  
83 =item * L<Slick::DatabaseExecutor>
84  
85 =item * L<Slick::DatabaseExecutor::MySQL>
86  
87 =item * L<Slick::DatabaseExecutor::Pg>
88  
89 =item * L<Slick::EventHandler>
90  
91 =item * L<Slick::Events>
92  
93 =item * L<Slick::Methods>
94  
95 =item * L<Slick::RouteMap>
96  
97 =item * L<Slick::Util>
98  
99 =back
100  
101 =cut
« Slick/RouteMap.pm ↑ Summary Slick/CacheExecutor/Memcached.pm »