| 1 | package HTTP::Proxy::HeaderFilter::simple; | ||||||||||
| 2 | 15 | $HTTP::Proxy::HeaderFilter::simple::VERSION = '0.304'; | |||||||||
| 3 | 15 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 15 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 15 | ▶ | use HTTP::Proxy::HeaderFilter; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 15 | ▶ | use vars qw( @ISA ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 15 | @ISA = qw( HTTP::Proxy::HeaderFilter ); | |||||||||
| 8 | |||||||||||
| 9 | 15 | my $methods = join '|', qw( begin filter end ); | |||||||||
| 10 | 15 | $methods = qr/^(?:$methods)$/; | |||||||||
| 11 | |||||||||||
| 12 | 9 | ▶ | sub init { | ||||||||
|
Subroutine
init: called CC=7 SCAR=27.6
Pod
documented
| |||||||||||
| 13 | 9 | my $self = shift; | |||||||||
| 14 | |||||||||||
| 15 | 9 | ▶ | croak "Constructor called without argument" unless @_; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 16 | 8 | ▶ | if ( @_ == 1 ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 17 | 8 | ▶ | croak "Single parameter must be a CODE reference" | ||||||||
|
Branch: 1 branch
| |||||||||||
| 18 | unless ref $_[0] eq 'CODE'; | ||||||||||
| 19 | 7 | $self->{_filter} = $_[0]; | |||||||||
| 20 | } | ||||||||||
| 21 | else { | ||||||||||
| 22 | 0 | ▶ | $self->{_filter} = sub { }; # default | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 23 | 0 | ▶ | while (@_) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | 0 | my ( $name, $code ) = splice @_, 0, 2; | |||||||||
| 25 | |||||||||||
| 26 | # basic error checking | ||||||||||
| 27 | 0 | ▶ | croak "Parameter to $name must be a CODE reference" | ||||||||
|
Branch: 1 branch
| |||||||||||
| 28 | unless ref $code eq 'CODE'; | ||||||||||
| 29 | 0 | ▶ | croak "Unkown method $name" unless $name =~ $methods; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 30 | |||||||||||
| 31 | 0 | $self->{"_$name"} = $code; | |||||||||
| 32 | } | ||||||||||
| 33 | } | ||||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | # transparently call the actual methods | ||||||||||
| 37 | 0 | ▶ | sub begin { goto &{ $_[0]{_begin} }; } | ||||||||
|
Subroutine
begin: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 38 | 4 | ▶ | sub filter { goto &{ $_[0]{_filter} }; } | ||||||||
|
Subroutine
filter: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 39 | 0 | ▶ | sub end { goto &{ $_[0]{_end} }; } | ||||||||
|
Subroutine
end: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 40 | |||||||||||
| 41 | 15 | ▶ | sub can { | ||||||||
|
Subroutine
can: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 42 | 15 | my ( $self, $method ) = @_; | |||||||||
| 43 | return $method =~ $methods | ||||||||||
| 44 | 15 | ▶ | ? $self->{"_$method"} | ||||||||
|
Branch: 1 branch
| |||||||||||
| 45 | : UNIVERSAL::can( $self, $method ); | ||||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | 15 | 1; | |||||||||
| 49 | |||||||||||
| 50 | __END__ | ||||||||||