| 1 | 19 | ▶ | use 5.010001; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 2 | 19 | ▶ | use strict; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 3 | 19 | ▶ | use warnings; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 4 | |||||||||||||||||||
| 5 | package Mite::Trait::HasRequiredMethods; | ||||||||||||||||||
| 6 | 19 | ▶ | use Mite::Miteception -role, -all; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 7 | |||||||||||||||||||
| 8 | 19 | our $AUTHORITY = 'cpan:TOBYINK'; | |||||||||||||||||
| 9 | 19 | our $VERSION = '0.013000'; | |||||||||||||||||
| 10 | |||||||||||||||||||
| 11 | has required_methods => | ||||||||||||||||||
| 12 | is => ro, | ||||||||||||||||||
| 13 | isa => ArrayRef[MethodName], | ||||||||||||||||||
| 14 | 10 | ▶ | builder => sub { [] }; | ||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 15 | |||||||||||||||||||
| 16 | 2 | ▶ | sub add_required_methods { | ||||||||||||||||
|
Subroutine
add_required_methods: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 17 | 2 | my $self = shift; | |||||||||||||||||
| 18 | |||||||||||||||||||
| 19 | 2 | push @{ $self->required_methods }, @_; | |||||||||||||||||
| 20 | |||||||||||||||||||
| 21 | 2 | return; | |||||||||||||||||
| 22 | } | ||||||||||||||||||
| 23 | |||||||||||||||||||
| 24 | 10 | ▶ | before inject_mite_functions => sub { | ||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||||||||||
| 25 | 10 | my ( $self, $file, $arg ) = ( shift, @_ ); | |||||||||||||||||
| 26 | |||||||||||||||||||
| 27 | 10 | ▶ | my $requested = sub { $arg->{$_[0]} ? 1 : $arg->{'!'.$_[0]} ? 0 : $arg->{'-all'} ? 1 : $_[1]; }; | ||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.5
Branch: 3 branches
| |||||||||||||||||||
| 28 | 10 | my $defaults = ! $arg->{'!-defaults'}; | |||||||||||||||||
| 29 | 10 | my $shim = $self->shim_name; | |||||||||||||||||
| 30 | 10 | my $package = $self->name; | |||||||||||||||||
| 31 | |||||||||||||||||||
| 32 | 19 | ▶ | no strict 'refs'; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 33 | |||||||||||||||||||
| 34 | 10 | ▶ | if ( $requested->( 'requires', $defaults ) ) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 35 | |||||||||||||||||||
| 36 | 10 | ▶ | *{ $package .'::requires' } = sub { | ||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 37 | 1 | $self->add_required_methods( @_ ); | |||||||||||||||||
| 38 | 1 | return; | |||||||||||||||||
| 39 | 10 | }; | |||||||||||||||||
| 40 | |||||||||||||||||||
| 41 | 10 | $self->imported_keywords->{requires} = 'sub {}'; | |||||||||||||||||
| 42 | } | ||||||||||||||||||
| 43 | 19 | }; | |||||||||||||||||
| 44 | |||||||||||||||||||
| 45 | 0 | ▶ | around _compile_mop_required_methods => sub { | ||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||
| 46 | 0 | my ( $next, $self ) = ( shift, shift ); | |||||||||||||||||
| 47 | |||||||||||||||||||
| 48 | 0 | my $code = $self->$next( @_ ); | |||||||||||||||||
| 49 | 0 | ▶ | $code .= "\n" if $code; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 50 | |||||||||||||||||||
| 51 | 0 | ▶ | if ( my @req = @{ $self->required_methods } ) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 52 | 0 | $code .= sprintf " \$PACKAGE->add_required_methods( %s );\n", | |||||||||||||||||
| 53 | join( q{, }, map B::perlstring( $_ ), @req ), | ||||||||||||||||||
| 54 | } | ||||||||||||||||||
| 55 | |||||||||||||||||||
| 56 | 0 | return $code; | |||||||||||||||||
| 57 | 19 | }; | |||||||||||||||||
| 58 | |||||||||||||||||||
| 59 | 19 | 1; | |||||||||||||||||