| 1 | package Catalyst::Seal::Guard; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 19 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 19 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 19 | our $VERSION = '0.04'; | |||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 19 | our %ORIGINAL; | |||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 220 | ▶ | sub replace { | ||||||||||||||||||
|
Subroutine
replace: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||
| 11 | 220 | my ($key, $code) = @_; | |||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | 19 | ▶ | my $orig = do { no strict 'refs'; *{$key}{CODE} }; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 14 | 220 | ▶ | unless ($orig) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 15 | 1 | require Catalyst::Seal; | |||||||||||||||||||
| 16 | 1 | Catalyst::Seal::note("$key does not exist, not patching"); | |||||||||||||||||||
| 17 | 1 | return 0; | |||||||||||||||||||
| 18 | } | ||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | 19 | ▶ | no strict 'refs'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 21 | 19 | ▶ | no warnings 'redefine'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 22 | 219 | ▶ | $ORIGINAL{$key} ||= $orig; | ||||||||||||||||||
|
Condition66%2/3
$Catalyst::Seal::Guard::ORIGINAL{$key} ||= $orig
MC/DC0%0/2
$Catalyst::Seal::Guard::ORIGINAL{$key} ||= $orig
$Catalyst::Seal::Guard::ORIGINAL{$key}
$orig
Truth table66%2/3
A ||= B
A= $Catalyst::Seal::Guard::ORIGINAL{$key}B= $orig
| |||||||||||||||||||||
| 23 | 219 | *{$key} = $code; | |||||||||||||||||||
| 24 | 219 | return 1; | |||||||||||||||||||
| 25 | } | ||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | 3 | ▶ | sub restore { | ||||||||||||||||||
|
Subroutine
restore: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 28 | 3 | my ($key) = @_; | |||||||||||||||||||
| 29 | 3 | ▶ | my $orig = delete $ORIGINAL{$key} or return 0; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 30 | 19 | ▶ | no strict 'refs'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 31 | 19 | ▶ | no warnings 'redefine'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 32 | 2 | *{$key} = $orig; | |||||||||||||||||||
| 33 | 2 | return 1; | |||||||||||||||||||
| 34 | } | ||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 19 | 1; | |||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | __END__ | ||||||||||||||||||||