| 1 | #!perl | ||||||||||||||||||||||||||||
| 2 | #PODNAME: Raisin::Request | ||||||||||||||||||||||||||||
| 3 | #ABSTRACT: Request class for Raisin. | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 15 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 15 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | package Raisin::Request; | ||||||||||||||||||||||||||||
| 9 | 15 | $Raisin::Request::VERSION = '0.94'; | |||||||||||||||||||||||||||
| 10 | 15 | ▶ | use parent 'Plack::Request'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 41 | ▶ | sub prepare_params { | ||||||||||||||||||||||||||
|
Subroutine
prepare_params: called CC=10 SCAR=23.0
Pod
documented
| |||||||||||||||||||||||||||||
| 13 | 41 | my ($self, $declared, $named) = @_; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 41 | $self->{'raisin.declared'} = $declared; | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | # PRECEDENCE: | ||||||||||||||||||||||||||||
| 18 | # - path | ||||||||||||||||||||||||||||
| 19 | # - query | ||||||||||||||||||||||||||||
| 20 | # - body | ||||||||||||||||||||||||||||
| 21 | my %params = ( | ||||||||||||||||||||||||||||
| 22 | 41 | ▶ | %{ $self->env->{'raisinx.body_params'} || {} }, | ||||||||||||||||||||||||||
|
Condition100%2/2
$self->env->{'raisinx.body_params'} || {}
MC/DC100%1/1
$self->env->{'raisinx.body_params'} || {}
$self->env->{'raisinx.body_params'}
Truth table100%2/2
A
A= $self->env->{'raisinx.body_params'}
| |||||||||||||||||||||||||||||
| 23 | 41 | ▶ | %{ $self->query_parameters->as_hashref_mixed || {} }, | ||||||||||||||||||||||||||
|
Condition50%1/2
$self->query_parameters->as_hashref_mixed || {}
MC/DC0%0/1
$self->query_parameters->as_hashref_mixed || {}
$self->query_parameters->as_hashref_mixed
Truth table50%1/2
A
A= $self->query_parameters->as_hashref_mixed
| |||||||||||||||||||||||||||||
| 24 | 41 | ▶ | %{ $named || {} }, | ||||||||||||||||||||||||||
|
Condition100%2/2
$named || {}
MC/DC100%1/1
$named || {}
$named
Truth table100%2/2
A
A= $named
| |||||||||||||||||||||||||||||
| 25 | ); | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 41 | $self->{'raisin.parameters'} = \%params; | |||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 41 | my $retval = 1; | |||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 41 | foreach my $p (@$declared) { | |||||||||||||||||||||||||||
| 32 | 69 | my $name = $p->name; | |||||||||||||||||||||||||||
| 33 | 69 | my $value = $params{$name}; | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 69 | ▶ | if (not $p->validate(\$value)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | 3 | $retval = 0; | |||||||||||||||||||||||||||
| 37 | 3 | ▶ | $p->required ? return : next; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 66 | ▶ | $value //= $p->default if defined $p->default; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$value //= $p->default
MC/DC0%0/2
$value //= $p->default
$value
$p->default
Truth table66%2/3
A //= B
A= $valueB= $p->default
| |||||||||||||||||||||||||||||
| 41 | 66 | ▶ | next if not defined($value); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 58 | $self->{'raisin.declared_params'}{$name} = $value; | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 39 | $retval; | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 35 | ▶ | sub declared_params { shift->{'raisin.declared_params'} } | ||||||||||||||||||||||||||
|
Subroutine
declared_params: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 50 | 4 | ▶ | sub raisin_parameters { shift->{'raisin.parameters'} } | ||||||||||||||||||||||||||
|
Subroutine
raisin_parameters: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 15 | 1; | |||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | __END__ | ||||||||||||||||||||||||||||