File Coverage

blib/lib/Router/Simple/SubMapper.pm
Criterion Covered Total %
statement 26 26 100.0
branch 1 2 50.0
condition 3 4 75.0
subroutine 7 7 100.0
pod 2 3 66.6
total 39 42 92.8


line stmt bran cond sub pod time code
1             package Router::Simple::SubMapper;
2 12     12   151 use strict;
  12         12  
  12         412  
3 12     12   52 use warnings;
  12         16  
  12         322  
4 12     12   53 use Scalar::Util qw/weaken/;
  12         22  
  12         1329  
5 12     12   55 use Router::Simple ();
  12         20  
  12         2117  
6              
7             sub new {
8 4     4 0 14 my ($class, %args) = @_;
9 4         17 my $self = bless { %args }, $class;
10 4         34 weaken($self->{parent});
11 4         45 $self;
12             }
13              
14             sub connect {
15 8     8 1 12 my ($self, $pattern, $dest, $opt) = @_;
16 8 50       26 $pattern = $self->{pattern}.$pattern if $self->{pattern};
17 8   50     14 $dest ||= +{};
18 8   100     24 $opt ||= +{};
19              
20 8         19 $self->{parent}->connect(
21             $pattern,
22 8         22 { %{ $self->{dest} }, %$dest },
23 8         10 { %{ $self->{opt} }, %$opt }
24             );
25              
26 8         25 $self; # chained method
27             }
28              
29             # Allow nested submapper calls
30             sub submapper {
31 1     1 1 2 my $self = shift;
32              
33 1         2 Router::Simple::submapper($self, @_);
34             }
35              
36              
37             1;
38             __END__