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 12     12   48 use strict;
  12         15  
  12         369  
3 12     12   48 use warnings;
  12         14  
  12         269  
4 12     12   49 use Scalar::Util qw/weaken/;
  12         17  
  12         2754  
5              
6             sub new {
7 3     3 0 12 my ($class, %args) = @_;
8 3         14 my $self = bless { %args }, $class;
9 3         20 weaken($self->{parent});
10 3         20 $self;
11             }
12              
13             sub connect {
14 6     6 1 10 my ($self, $pattern, $dest, $opt) = @_;
15 6 50       22 $pattern = $self->{pattern}.$pattern if $self->{pattern};
16 6   50     37 $dest ||= +{};
17 6   50     22 $opt ||= +{};
18              
19 6         19 $self->{parent}->connect(
20             $pattern,
21 6         20 { %{ $self->{dest} }, %$dest },
22 6         10 { %{ $self->{opt} }, %$opt }
23             );
24              
25 6         24 $self; # chained method
26             }
27              
28             1;
29             __END__