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   2410 use warnings;
  6         9  
  6         194  
4 6     6   28 use strict;
  6         7  
  6         154  
5 6     6   24 use true;
  6         7  
  6         27  
6              
7             sub import {
8 6     6   42 my $routes = {};
9 6         13 my $caller = caller;
10 6         66 strict->import();
11 6         44 warnings->import();
12 6         30 true->import();
13             {
14 6     6   5501 no strict 'refs';
  6         8  
  6         1590  
  6         4459  
15 6         7 push @{"${caller}::ISA"}, 'Kelp';
  6         70  
16 6     0   20 *{"${caller}::new"} = sub { return shift->SUPER::new(@_); };
  6         25  
  0         0  
17              
18 6         22 *{"${caller}::get"} = sub {
19 30     30   83 my ($name, $coderef) = @_;
20 30         295 $routes->{$name} = {
21             type => 'get',
22             coderef => $coderef,
23             };
24 6         18 };
25              
26 6         25 *{"${caller}::post"} = sub {
27 0     0   0 my ($name, $coderef) = @_;
28 0         0 $routes->{$name} = {
29             type => 'post',
30             coderef => $coderef,
31             };
32 6         14 };
33              
34 6         22 *{"${caller}::any"} = sub {
35 0     0   0 my ($name, $coderef) = @_;
36 0         0 $routes->{$name} = {
37             type => 'any',
38             coderef => $coderef,
39             };
40 6         13 };
41              
42 6         18 *{"${caller}::bridge"} = sub {
43 6     6   16 my ($name, $coderef, $type) = @_;
44 6   50     37 $type //= 'get';
45 6         18 $routes->{$name} = {
46             type => $type,
47             coderef => $coderef,
48             bridge => 1,
49             };
50 6         15 };
51              
52 6         630 *{"${caller}::get_routes"} = sub {
53 6     6   23 return $routes;
54 6         15 };
55             }
56             }
57              
58             1;
59             __END__