line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::MOP::MiniTrait; |
2
|
|
|
|
|
|
|
our $VERSION = '2.2203'; |
3
|
|
|
|
|
|
|
|
4
|
462
|
|
|
462
|
|
3041
|
use strict; |
|
462
|
|
|
|
|
883
|
|
|
462
|
|
|
|
|
13213
|
|
5
|
462
|
|
|
462
|
|
2422
|
use warnings; |
|
462
|
|
|
|
|
804
|
|
|
462
|
|
|
|
|
11580
|
|
6
|
|
|
|
|
|
|
|
7
|
462
|
|
|
462
|
|
2242
|
use Module::Runtime 'use_package_optimistically'; |
|
462
|
|
|
|
|
786
|
|
|
462
|
|
|
|
|
3014
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub apply { |
10
|
2671
|
|
|
2671
|
0
|
8793
|
my ( $to_class, $trait ) = @_; |
11
|
|
|
|
|
|
|
|
12
|
2671
|
|
|
|
|
11585
|
for ( grep { !ref } $to_class, $trait ) { |
|
5342
|
|
|
|
|
15386
|
|
13
|
4643
|
|
|
|
|
21040
|
use_package_optimistically($_); |
14
|
4643
|
|
|
|
|
232728
|
$_ = Class::MOP::Class->initialize($_); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
2671
|
|
|
|
|
10543
|
for my $meth ( grep { $_->package_name ne 'UNIVERSAL' } $trait->get_all_methods ) { |
|
30933
|
|
|
|
|
60650
|
|
18
|
20255
|
|
|
|
|
49233
|
my $meth_name = $meth->name; |
19
|
20255
|
100
|
|
|
|
51530
|
next if index($meth_name, '__') == 0; # skip private subs |
20
|
|
|
|
|
|
|
|
21
|
19556
|
100
|
|
|
|
43427
|
if ( $to_class->find_method_by_name($meth_name) ) { |
22
|
14787
|
|
|
|
|
47363
|
$to_class->add_around_method_modifier( $meth_name, $meth->body ); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
else { |
25
|
4769
|
|
|
|
|
16543
|
$to_class->add_method( $meth_name, $meth->clone ); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# We can't load this with use, since it may be loaded and used from Class::MOP |
31
|
|
|
|
|
|
|
# (via Class::MOP::Class, etc). However, if for some reason this module is loaded |
32
|
|
|
|
|
|
|
# _without_ first loading Class::MOP we need to require Class::MOP so we can |
33
|
|
|
|
|
|
|
# use it and Class::MOP::Class. |
34
|
|
|
|
|
|
|
require Class::MOP; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
1; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# ABSTRACT: Extremely limited trait application |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
__END__ |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=pod |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=encoding UTF-8 |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 NAME |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Class::MOP::MiniTrait - Extremely limited trait application |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 VERSION |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
version 2.2203 |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 DESCRIPTION |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
This package provides a single function, C<apply>, which does a half-assed job |
57
|
|
|
|
|
|
|
of applying a trait to a class. It exists solely for use inside Class::MOP and |
58
|
|
|
|
|
|
|
L<Moose> core classes. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 AUTHORS |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=over 4 |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=item * |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Stevan Little <stevan@cpan.org> |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=item * |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Dave Rolsky <autarch@urth.org> |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=item * |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Jesse Luehrs <doy@cpan.org> |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=item * |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Shawn M Moore <sartak@cpan.org> |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=item * |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org> |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=item * |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Karen Etheridge <ether@cpan.org> |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item * |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Florian Ragwitz <rafl@debian.org> |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=item * |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Hans Dieter Pearcey <hdp@cpan.org> |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=item * |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Chris Prather <chris@prather.org> |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=item * |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Matt S Trout <mstrout@cpan.org> |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=back |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
This software is copyright (c) 2006 by Infinity Interactive, Inc. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
111
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=cut |