| 1 | package Mojolicious::Plugin::Parametry::ParamerHelpers; | ||||||||||
| 2 | |||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 3 | ▶ | use Mojo::Collection; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 3 | our $VERSION = '1.001002'; # VERSION | |||||||||
| 8 | |||||||||||
| 9 | 16 | ▶ | sub new { bless { _c => $_[1] }, $_[0] } | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 10 | |||||||||||
| 11 | 16 | ▶ | sub matching { | ||||||||
|
Subroutine
matching: called CC=6 SCAR=18.0
Pod
undocumented
| |||||||||||
| 12 | 16 | my ($self, $re, %args) = @_; | |||||||||
| 13 | 16 | my $c = $self->{_c}; | |||||||||
| 14 | |||||||||||
| 15 | 16 | ▶ | $re = qr/^\Q$re\E/ unless ref $re eq 'Regexp'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 16 | 16 | my $params = Mojo::Collection->new(grep /$re/, $c->req->params->names->@*); | |||||||||
| 17 | |||||||||||
| 18 | |||||||||||
| 19 | 16 | ▶ | if ($args{as_hash}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 20 | 8 | ▶ | return +{ $params->map(sub { | ||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||
| 21 | 8 | my $orig_name = $_; | |||||||||
| 22 | 8 | ▶ | $args{subst} and s/$re/$args{subst}/; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | 8 | ▶ | $args{strip} and s/$re//; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | 8 | $_ => $c->param($orig_name) | |||||||||
| 25 | 4 | })->each } | |||||||||
| 26 | } | ||||||||||
| 27 | |||||||||||
| 28 | $args{vals} | ||||||||||
| 29 | 12 | ▶ | and return $params->map(sub {$c->param($_)}); | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||
| 30 | |||||||||||
| 31 | 0 | ▶ | $args{subst} and $params = $params->map(sub {s/$re/$args{subst}/r}); | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
Branch: 1 branch
| |||||||||||
| 32 | 8 | ▶ | $args{strip} and $params = $params->map(sub {s/$re//r}); | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||
| 33 | 8 | $params | |||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | 3 | 1; | |||||||||
| 37 | |||||||||||
| 38 | __END__ | ||||||||||