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