File Coverage

blib/lib/Router/Simple/SubMapper.pm
Criterion Covered Total %
statement 21 21 100.0
branch 1 2 50.0
condition 2 4 50.0
subroutine 5 5 100.0
pod 1 2 50.0
total 30 34 88.2


line stmt bran cond sub pod time code
1             package Router::Simple::SubMapper;
2 11     11   126 use strict;
  11         18  
  11         607  
3 11     11   57 use warnings;
  11         20  
  11         405  
4 11     11   60 use Scalar::Util qw/weaken/;
  11         31  
  11         3751  
5              
6             sub new {
7 3     3 0 14 my ($class, %args) = @_;
8 3         16 my $self = bless { %args }, $class;
9 3         18 weaken($self->{parent});
10 3         23 $self;
11             }
12              
13             sub connect {
14 6     6 1 11 my ($self, $pattern, $dest, $opt) = @_;
15 6 50       24 $pattern = $self->{pattern}.$pattern if $self->{pattern};
16 6   50     37 $dest ||= +{};
17 6   50     24 $opt ||= +{};
18              
19 6         24 $self->{parent}->connect(
20             $pattern,
21 6         27 { %{ $self->{dest} }, %$dest },
22 6         12 { %{ $self->{opt} }, %$opt }
23             );
24              
25 6         25 $self; # chained method
26             }
27              
28             1;
29             __END__