/usr/share/perl5/Router/Simple/SubMapper.pm is in librouter-simple-perl 0.17-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | package Router::Simple::SubMapper;
use strict;
use warnings;
use Scalar::Util qw/weaken/;
use Router::Simple ();
sub new {
my ($class, %args) = @_;
my $self = bless { %args }, $class;
weaken($self->{parent});
$self;
}
sub connect {
my ($self, $pattern, $dest, $opt) = @_;
$pattern = $self->{pattern}.$pattern if $self->{pattern};
$dest ||= +{};
$opt ||= +{};
$self->{parent}->connect(
$pattern,
{ %{ $self->{dest} }, %$dest },
{ %{ $self->{opt} }, %$opt }
);
$self; # chained method
}
# Allow nested submapper calls
sub submapper {
my $self = shift;
Router::Simple::submapper($self, @_);
}
1;
__END__
=for stopwords submapper
=head1 NAME
Router::Simple::SubMapper - submapper
=head1 SYNOPSIS
use Router::Simple;
my $router = Router::Simple->new();
my $s = $router->submapper('/entry/{id}', {controller => 'Entry'});
$s->connect('/edit' => {action => 'edit'})
->connect('/show' => {action => 'show'});
=head1 DESCRIPTION
Router::Simple::SubMapper is sub-mapper for L<Router::Simple>.
This class provides shorthand to create routes, that have common parts.
=head1 METHODS
=over 4
=item my $submapper = $router->submapper(%args);
Do not call this method directly.You should create new instance from $router->submapper(%args).
=item $submapper->connect(@args)
This method creates new route to parent $router with @args and arguments of ->submapper().
This method returns $submapper itself for method-chain.
=item $submapper->submapper(%args)
submapper() can be called recursively to build nested routes.
This method returns $submapper itself for method-chain.
=back
=head1 SEE ALSO
L<Router::Simple>
|