| 1 | package Die::Hard; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use 5.008; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Scalar::Util (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Carp (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use if $] < 5.010, 'UNIVERSAL::DOES'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | no warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | $Die::Hard::AUTHORITY = 'cpan:TOBYINK'; | |||||||||||||||||||||||||||
| 12 | 1 | $Die::Hard::VERSION = '0.004'; | |||||||||||||||||||||||||||
| 13 | } | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | has proxy_for => ( | ||||||||||||||||||||||||||||
| 16 | is => 'ro', | ||||||||||||||||||||||||||||
| 17 | 1 | ▶ | isa => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||
| 18 | 1 | ▶ | Scalar::Util::blessed($_[0]) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 19 | or Carp::confess("proxy_for must be a blessed object") | ||||||||||||||||||||||||||||
| 20 | }, | ||||||||||||||||||||||||||||
| 21 | 1 | required => 1, | |||||||||||||||||||||||||||
| 22 | ); | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 1 | has last_error => ( | |||||||||||||||||||||||||||
| 25 | is => 'ro', | ||||||||||||||||||||||||||||
| 26 | required => 0, | ||||||||||||||||||||||||||||
| 27 | writer => '_set_last_error', | ||||||||||||||||||||||||||||
| 28 | clearer => '_clear_last_error', | ||||||||||||||||||||||||||||
| 29 | ); | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | sub BUILDARGS | ||||||||||||||||||||||||||||
| 32 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
BUILDARGS: called CC=3 SCAR=14.2
Pod
documented
| |||||||||||||||||||||||||||||
| 33 | 1 | my $class = shift; | |||||||||||||||||||||||||||
| 34 | 1 | ▶ | return +{ proxy_for => $_[0] } if @_ == 1 && Scalar::Util::blessed($_[0]); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@_ == 1 and builtin::blessed($_[0])
MC/DC0%0/2
@_ == 1 and builtin::blessed($_[0])
@_ == 1
builtin::blessed($_[0])
Truth table33%1/3
A and B
A= @_ == 1B= builtin::blessed($_[0])
| |||||||||||||||||||||||||||||
| 35 | 0 | return $class->SUPER::BUILDARGS(@_); | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | sub AUTOLOAD | ||||||||||||||||||||||||||||
| 39 | 3 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: called CC=7 SCAR=21.8
| |||||||||||||||||||||||||||||
| 40 | 3 | my ($meth) = (our $AUTOLOAD =~ /::([^:]+)$/); | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 3 | local $@ = undef; | |||||||||||||||||||||||||||
| 43 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 3 | $self->_clear_last_error; | |||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 3 | ▶ | my $coderef = $self->proxy_for->can($meth) || $meth; | ||||||||||||||||||||||||||
|
Condition66%2/3
$self->proxy_for->can($meth) || $meth
MC/DC0%0/2
$self->proxy_for->can($meth) || $meth
$self->proxy_for->can($meth)
$meth
Truth table66%2/3
A || B
A= $self->proxy_for->can($meth)B= $meth
| |||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 3 | ▶ | if (wantarray) | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 50 | { | ||||||||||||||||||||||||||||
| 51 | 0 | my @r; | |||||||||||||||||||||||||||
| 52 | $self->_set_last_error($@) | ||||||||||||||||||||||||||||
| 53 | 0 | ▶ | unless eval { @r = $self->proxy_for->$coderef(@_); 1 }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | 0 | return @r; | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | elsif (defined wantarray) | ||||||||||||||||||||||||||||
| 57 | { | ||||||||||||||||||||||||||||
| 58 | 2 | my $r; | |||||||||||||||||||||||||||
| 59 | $self->_set_last_error($@) | ||||||||||||||||||||||||||||
| 60 | 2 | ▶ | unless eval { $r = $self->proxy_for->$coderef(@_); 1 }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | 2 | return $r; | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | else | ||||||||||||||||||||||||||||
| 64 | { | ||||||||||||||||||||||||||||
| 65 | $self->_set_last_error($@) | ||||||||||||||||||||||||||||
| 66 | 0 | ▶ | unless eval { $self->proxy_for->$coderef(@_); 1 }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | 1 | return; | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | sub can | ||||||||||||||||||||||||||||
| 72 | 13 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
can: called CC=4 SCAR=14.6
Pod
documented
| |||||||||||||||||||||||||||||
| 73 | 13 | my ($self, $method) = @_; | |||||||||||||||||||||||||||
| 74 | 13 | ▶ | return $self->SUPER::can($method) unless Scalar::Util::blessed($self); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 7 | my $i_can = $self->SUPER::can($method); | |||||||||||||||||||||||||||
| 77 | 7 | my $he_can = $self->proxy_for->can($method); | |||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 7 | ▶ | return $i_can if $i_can; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 80 | 0 | ▶ | return sub { our $AUTOLOAD = $method; goto \&AUTOLOAD } if $he_can; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=2.0
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 81 | 0 | return; | |||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | sub DOES | ||||||||||||||||||||||||||||
| 85 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
DOES: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 86 | 0 | my ($self, $role) = @_; | |||||||||||||||||||||||||||
| 87 | 0 | ▶ | return $self->SUPER::DOES($role) unless Scalar::Util::blessed($self); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 88 | 0 | ▶ | $self->SUPER::DOES($role) or $self->proxy_for->DOES($role); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | sub isa | ||||||||||||||||||||||||||||
| 92 | 3 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
isa: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||
| 93 | 3 | my ($self, $role) = @_; | |||||||||||||||||||||||||||
| 94 | 3 | ▶ | return $self->SUPER::isa($role) unless Scalar::Util::blessed($self); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 95 | 3 | ▶ | $self->SUPER::isa($role) or $self->proxy_for->isa($role); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 1 | ▶ | no Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 1 | 1; | |||||||||||||||||||||||||||
| 101 | __END__ | ||||||||||||||||||||||||||||