line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::MOP::MiniTrait; |
2
|
|
|
|
|
|
|
our $VERSION = '2.2206'; |
3
|
|
|
|
|
|
|
|
4
|
450
|
|
|
450
|
|
3374
|
use strict; |
|
450
|
|
|
|
|
983
|
|
|
450
|
|
|
|
|
14421
|
|
5
|
450
|
|
|
450
|
|
2419
|
use warnings; |
|
450
|
|
|
|
|
1089
|
|
|
450
|
|
|
|
|
12832
|
|
6
|
|
|
|
|
|
|
|
7
|
450
|
|
|
450
|
|
2501
|
use Module::Runtime 'use_package_optimistically'; |
|
450
|
|
|
|
|
1018
|
|
|
450
|
|
|
|
|
3506
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub apply { |
10
|
2598
|
|
|
2598
|
0
|
10368
|
my ( $to_class, $trait ) = @_; |
11
|
|
|
|
|
|
|
|
12
|
2598
|
|
|
|
|
12255
|
for ( grep { !ref } $to_class, $trait ) { |
|
5196
|
|
|
|
|
17197
|
|
13
|
4515
|
|
|
|
|
22551
|
use_package_optimistically($_); |
14
|
4515
|
|
|
|
|
265469
|
$_ = Class::MOP::Class->initialize($_); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
2598
|
|
|
|
|
13715
|
for my $meth ( grep { $_->package_name ne 'UNIVERSAL' } $trait->get_all_methods ) { |
|
30111
|
|
|
|
|
71759
|
|
18
|
19725
|
|
|
|
|
56277
|
my $meth_name = $meth->name; |
19
|
19725
|
100
|
|
|
|
60097
|
next if index($meth_name, '__') == 0; # skip private subs |
20
|
|
|
|
|
|
|
|
21
|
19044
|
100
|
|
|
|
48254
|
if ( $to_class->find_method_by_name($meth_name) ) { |
22
|
14402
|
|
|
|
|
54555
|
$to_class->add_around_method_modifier( $meth_name, $meth->body ); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
else { |
25
|
4642
|
|
|
|
|
20481
|
$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.2206 |
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 |