| 1 | package Plack::Component; | ||||||||||||||||||||||||||||
| 2 | 108 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 108 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 108 | ▶ | use Carp (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 108 | ▶ | use Plack::Util; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 108 | ▶ | use overload '&{}' => \&to_app_auto, fallback => 1; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 290 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=14.1
Pod
documented
| |||||||||||||||||||||||||||||
| 9 | 290 | my $proto = shift; | |||||||||||||||||||||||||||
| 10 | 290 | ▶ | my $class = ref $proto || $proto; | ||||||||||||||||||||||||||
|
Condition33%1/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 290 | my $self; | |||||||||||||||||||||||||||
| 13 | 290 | ▶ | if (@_ == 1 && ref $_[0] eq 'HASH') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@_ == 1 and ref $_[0] eq "HASH"
MC/DC50%1/2
@_ == 1 and ref $_[0] eq "HASH"
@_ == 1
ref $_[0] eq "HASH"
Truth table66%2/3
A and B
A= @_ == 1B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||
| 14 | 213 | $self = bless {%{$_[0]}}, $class; | |||||||||||||||||||||||||||
| 15 | } else { | ||||||||||||||||||||||||||||
| 16 | 77 | $self = bless {@_}, $class; | |||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 290 | $self; | |||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 134 | ▶ | sub to_app_auto { | ||||||||||||||||||||||||||
|
Subroutine
to_app_auto: called CC=3 SCAR=13.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 23 | 134 | my $self = shift; | |||||||||||||||||||||||||||
| 24 | 134 | ▶ | if (($ENV{PLACK_ENV} || '') eq 'development') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$ENV{'PLACK_ENV'} || ''
MC/DC0%0/1
$ENV{'PLACK_ENV'} || ''
$ENV{'PLACK_ENV'}
Truth table50%1/2
A
A= $ENV{'PLACK_ENV'}
| |||||||||||||||||||||||||||||
| 25 | 0 | my $class = ref($self); | |||||||||||||||||||||||||||
| 26 | 0 | warn "WARNING: Automatically converting $class instance to a PSGI code reference. " . | |||||||||||||||||||||||||||
| 27 | "If you see this warning for each request, you probably need to explicitly call " . | ||||||||||||||||||||||||||||
| 28 | "to_app() i.e. $class->new(...)->to_app in your PSGI file.\n"; | ||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | 134 | $self->to_app(@_); | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | # NOTE: | ||||||||||||||||||||||||||||
| 34 | # this is for back-compat only, | ||||||||||||||||||||||||||||
| 35 | # future modules should use | ||||||||||||||||||||||||||||
| 36 | # Plack::Util::Accessor directly | ||||||||||||||||||||||||||||
| 37 | # or their own favorite accessor | ||||||||||||||||||||||||||||
| 38 | # generator. | ||||||||||||||||||||||||||||
| 39 | # - SL | ||||||||||||||||||||||||||||
| 40 | 0 | ▶ | sub mk_accessors { | ||||||||||||||||||||||||||
|
Subroutine
mk_accessors: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 41 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 42 | 0 | ▶ | Plack::Util::Accessor::mk_accessors( ref( $self ) || $self, @_ ) | ||||||||||||||||||||||||||
|
Condition0%0/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table0%0/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 292 | ▶ | sub prepare_app { return } | ||||||||||||||||||||||||||
|
Subroutine
prepare_app: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 351 | ▶ | sub to_app { | ||||||||||||||||||||||||||
|
Subroutine
to_app: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 48 | 351 | my $self = shift; | |||||||||||||||||||||||||||
| 49 | 351 | $self->prepare_app; | |||||||||||||||||||||||||||
| 50 | 351 | ▶ | return sub { $self->call(@_) }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 765 | ▶ | sub response_cb { | ||||||||||||||||||||||||||
|
Subroutine
response_cb: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 55 | 765 | my($self, $res, $cb) = @_; | |||||||||||||||||||||||||||
| 56 | 765 | Plack::Util::response_cb($res, $cb); | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 108 | 1; | |||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | __END__ | ||||||||||||||||||||||||||||