File Coverage

blib/lib/KelpX/Sweet/Route.pm
Criterion Covered Total %
statement 38 43 88.3
branch n/a
condition 1 2 50.0
subroutine 8 11 72.7
pod n/a
total 47 56 83.9


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