line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::Method::ModifiersX::Override; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
104267
|
use 5.008; |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
130
|
|
4
|
2
|
|
|
2
|
|
13
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
100
|
|
5
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
92
|
|
6
|
2
|
|
|
2
|
|
17
|
no warnings qw( once void uninitialized ); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
166
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
BEGIN { |
9
|
2
|
|
|
2
|
|
5
|
$Class::Method::ModifiersX::Override::AUTHORITY = 'cpan:TOBYINK'; |
10
|
2
|
|
|
|
|
85
|
$Class::Method::ModifiersX::Override::VERSION = '0.001'; |
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
|
13
|
2
|
|
|
2
|
|
11
|
use base qw(Exporter); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
1560
|
|
14
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
15
|
|
|
|
|
|
|
all => [our @EXPORT_OK = our @EXPORT = qw( override super )], |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
2
|
|
|
2
|
|
3544
|
use Class::Method::Modifiers qw( install_modifier ); |
|
2
|
|
|
|
|
6754
|
|
|
2
|
|
|
|
|
745
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $SUPER_PACKAGE = undef; |
21
|
|
|
|
|
|
|
our $SUPER_BODY = undef; |
22
|
|
|
|
|
|
|
our @SUPER_ARGS = (); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub _mk_around |
25
|
|
|
|
|
|
|
{ |
26
|
2
|
|
|
2
|
|
3
|
my ($into, $code) = @_; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
return sub { |
29
|
6
|
|
|
6
|
|
2182
|
local $SUPER_PACKAGE = $into; |
30
|
6
|
|
|
|
|
14
|
local $SUPER_BODY = shift; |
31
|
6
|
|
|
|
|
15
|
local @SUPER_ARGS = @_; |
32
|
6
|
|
|
|
|
16
|
return $code->(@_); |
33
|
|
|
|
|
|
|
} |
34
|
2
|
|
|
|
|
15
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub override |
37
|
|
|
|
|
|
|
{ |
38
|
2
|
|
|
2
|
1
|
506
|
my $into = caller(0); |
39
|
2
|
|
|
|
|
6
|
my $code = pop; |
40
|
2
|
|
|
|
|
7
|
my @name = @_; |
41
|
|
|
|
|
|
|
|
42
|
2
|
|
|
|
|
8
|
my $sub = _mk_around($into, $code); |
43
|
2
|
|
|
|
|
12
|
install_modifier($into, 'around', @name, $sub); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub super () |
47
|
|
|
|
|
|
|
{ |
48
|
6
|
50
|
|
6
|
1
|
29
|
return unless defined $SUPER_BODY; |
49
|
6
|
50
|
33
|
|
|
39
|
return if defined $SUPER_PACKAGE && $SUPER_PACKAGE ne caller; |
50
|
6
|
|
|
|
|
90
|
$SUPER_BODY->(@SUPER_ARGS); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__END__ |