| 1 | 1 | ▶ | use 5.008; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | package Role::Commons::Tap; | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Carp qw[croak]; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Moo::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | $Role::Commons::Tap::AUTHORITY = 'cpan:TOBYINK'; | |||||||||||||||||||||||||||
| 12 | 1 | $Role::Commons::Tap::VERSION = '0.104'; | |||||||||||||||||||||||||||
| 13 | } | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 1 | ▶ | our $setup_for_class = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 1 | my ($role, $package, %args) = @_; | |||||||||||||||||||||||||||
| 17 | 1 | return 0; | |||||||||||||||||||||||||||
| 18 | 1 | }; | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | sub tap | ||||||||||||||||||||||||||||
| 21 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
tap: called CC=10 SCAR=30.7
Pod
documented
| |||||||||||||||||||||||||||||
| 22 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 23 | 1 | my %flags; | |||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 1 | ▶ | PARAM: while (@_) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | { | ||||||||||||||||||||||||||||
| 27 | 1 | my $next = shift; | |||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 1 | ▶ | if (ref($next) eq 'CODE' or not ref $next) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $next eq "CODE" or not ref $next
MC/DC0%0/2
ref $next eq "CODE" or not ref $next
ref $next eq "CODE"
not ref $next
Truth table33%1/3
A or not(B)
A= ref $next eq "CODE"B= not ref $next
| |||||||||||||||||||||||||||||
| 30 | { | ||||||||||||||||||||||||||||
| 31 | 1 | ▶ | my $args = ref($_[0]) eq 'ARRAY' ? shift : []; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 32 | 1 | ▶ | my $code = ref $next ? $next : sub { $self->$next(@_) }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.2
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 1 | ▶ | if ($flags{ EVAL }) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | { | ||||||||||||||||||||||||||||
| 36 | 0 | local $_ = $self; | |||||||||||||||||||||||||||
| 37 | 0 | eval { $code->(@$args) } | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | else | ||||||||||||||||||||||||||||
| 40 | { | ||||||||||||||||||||||||||||
| 41 | 1 | local $_ = $self; | |||||||||||||||||||||||||||
| 42 | 1 | do { $code->(@$args) } | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | 1 | next PARAM; | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 0 | ▶ | if (ref($next) eq 'SCALAR') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | { | ||||||||||||||||||||||||||||
| 49 | 0 | ▶ | if ($$next =~ m{^(no_?)?(.+)$}i) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 50 | { | ||||||||||||||||||||||||||||
| 51 | 0 | ▶ | $flags{ uc $2 } = $1 ? 0 : 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | 0 | next PARAM; | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 0 | croak qq/Unsupported parameter to tap: $next/; | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 1 | return $self; | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 1 | 1; | |||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | __END__ | ||||||||||||||||||||||||||||