| 1 | 1 | ▶ | use 5.014; | ||||||||
|
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 Kavorka::TraitFor::Sub::override; | ||||||||||
| 6 | |||||||||||
| 7 | 1 | our $AUTHORITY = 'cpan:TOBYINK'; | |||||||||
| 8 | 1 | our $VERSION = '0.039'; | |||||||||
| 9 | |||||||||||
| 10 | 1 | ▶ | use Moo::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 1 | ▶ | use Types::Standard qw(Any); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 1 | ▶ | use Carp qw(croak); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 1 | ▶ | use namespace::sweep; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | |||||||||||
| 15 | before install_sub => sub | ||||||||||
| 16 | 3 | ▶ | { | ||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.5
| |||||||||||
| 17 | 3 | my $self = shift; | |||||||||
| 18 | |||||||||||
| 19 | 3 | ▶ | croak("The 'override' trait cannot be applied to lexical methods") | ||||||||
|
Branch: 1 branch
| |||||||||||
| 20 | if $self->is_lexical; | ||||||||||
| 21 | |||||||||||
| 22 | 3 | ▶ | croak("The 'override' trait cannot be applied to anonymous methods") | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | if $self->is_anonymous; | ||||||||||
| 24 | |||||||||||
| 25 | 3 | ▶ | croak("The 'override' trait may only be applied to methods") | ||||||||
|
Branch: 1 branch
| |||||||||||
| 26 | if $self->invocation_style ne 'method'; | ||||||||||
| 27 | |||||||||||
| 28 | 3 | my ($pkg, $name) = ($self->qualified_name =~ /^(.+)::(\w+)$/); | |||||||||
| 29 | 3 | ▶ | return if $pkg->can($name); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 30 | |||||||||||
| 31 | 1 | croak("Method '$name' does not exist in inheritance hierarchy; cannot override"); | |||||||||
| 32 | 1 | }; | |||||||||
| 33 | |||||||||||
| 34 | 1 | 1; | |||||||||