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
3
|
|
|
1
|
|
|
|
|
23
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
24
|
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
24
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
|
1
|
|
|
|
|
4
|
|
5
|
|
|
|
|
|
|
require Class::Trait; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.31'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub apply { |
10
|
5
|
|
|
5
|
1
|
4958
|
my ($trait, $instance) = @_; |
11
|
5
|
|
|
|
|
17
|
Class::Trait->apply($instance, $trait); |
12
|
3
|
|
|
|
|
36
|
return $trait; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# all that is here is an AUTOLOAD method which is used to fix the SUPER call |
16
|
|
|
|
|
|
|
# method resolution problem introduced when a trait calls a method in a SUPER |
17
|
|
|
|
|
|
|
# class since SUPER should be bound after the trait is flattened and not |
18
|
|
|
|
|
|
|
# before. |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub AUTOLOAD { |
21
|
4
|
|
|
4
|
|
55
|
my $auto_load = our $AUTOLOAD; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# we dont want to mess with DESTORY |
24
|
4
|
50
|
|
|
|
18
|
return if ( $auto_load =~ m/DESTROY/ ); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# if someone is attempting a call to |
27
|
|
|
|
|
|
|
# SUPER, then we need to handle this. |
28
|
4
|
50
|
|
|
|
294
|
if ( my ($super_method) = $auto_load =~ /(SUPER::.*)/ ) { |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# get our arguemnts |
31
|
4
|
|
|
|
|
22
|
my ( $self, @args ) = @_; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# lets get the intended method name |
34
|
4
|
|
|
|
|
12
|
$super_method = scalar( caller 1 ) . '::' . $super_method; |
35
|
4
|
|
|
|
|
43
|
return $self->$super_method(@args); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# if it was not a call to SUPER, then |
39
|
|
|
|
|
|
|
# we need to let this fail, as it is |
40
|
|
|
|
|
|
|
# not our problem |
41
|
1
|
|
|
|
|
3
|
die "undefined method ($auto_load) in trait\n"; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
__END__ |