File Coverage

blib/lib/KelpX/Sweet/Route.pm
Criterion Covered Total %
statement 35 43 81.4
branch n/a
condition 0 2 0.0
subroutine 7 11 63.6
pod n/a
total 42 56 75.0


line stmt bran cond sub pod time code
1             package KelpX::Sweet::Route;
2              
3 1     1   381 use warnings;
  1         1  
  1         26  
4 1     1   3 use strict;
  1         2  
  1         20  
5 1     1   3 use true;
  1         1  
  1         3  
6              
7             sub import {
8 1     1   6 my $routes = {};
9 1         3 my $caller = caller;
10 1         10 strict->import();
11 1         7 warnings->import();
12 1         2 true->import();
13             {
14 1     1   862 no strict 'refs';
  1         2  
  1         237  
  1         721  
15 1         2 push @{"${caller}::ISA"}, 'Kelp';
  1         11  
16 1     0   3 *{"${caller}::new"} = sub { return shift->SUPER::new(@_); };
  1         4  
  0         0  
17              
18 1         2 *{"${caller}::get"} = sub {
19 1     1   3 my ($name, $coderef) = @_;
20 1         33 $routes->{$name} = {
21             type => 'get',
22             coderef => $coderef,
23             };
24 1         3 };
25              
26 1         3 *{"${caller}::post"} = sub {
27 0     0   0 my ($name, $coderef) = @_;
28 0         0 $routes->{$name} = {
29             type => 'post',
30             coderef => $coderef,
31             };
32 1         3 };
33              
34 1         3 *{"${caller}::any"} = sub {
35 0     0   0 my ($name, $coderef) = @_;
36 0         0 $routes->{$name} = {
37             type => 'any',
38             coderef => $coderef,
39             };
40 1         2 };
41              
42 1         3 *{"${caller}::bridge"} = sub {
43 0     0   0 my ($name, $coderef, $type) = @_;
44 0   0     0 $type //= 'get';
45 0         0 $routes->{$name} = {
46             type => $type,
47             coderef => $coderef,
48             bridge => 1,
49             };
50 1         2 };
51              
52 1         37 *{"${caller}::get_routes"} = sub {
53 1     1   3 return $routes;
54 1         2 };
55             }
56             }
57              
58             1;
59             __END__