line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package metaclass; |
2
|
|
|
|
|
|
|
our $VERSION = '2.2203'; |
3
|
|
|
|
|
|
|
|
4
|
440
|
|
|
440
|
|
990035
|
use strict; |
|
440
|
|
|
|
|
902
|
|
|
440
|
|
|
|
|
11793
|
|
5
|
440
|
|
|
440
|
|
2388
|
use warnings; |
|
440
|
|
|
|
|
786
|
|
|
440
|
|
|
|
|
12551
|
|
6
|
|
|
|
|
|
|
|
7
|
440
|
|
|
440
|
|
10637
|
use Module::Runtime 'use_package_optimistically', 'use_module'; |
|
440
|
|
|
|
|
31962
|
|
|
440
|
|
|
|
|
2942
|
|
8
|
440
|
|
|
440
|
|
33219
|
use Class::MOP; |
|
440
|
|
|
|
|
941
|
|
|
440
|
|
|
|
|
113797
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub import { |
11
|
8041
|
|
|
8041
|
|
41850
|
my ( $class, @args ) = @_; |
12
|
|
|
|
|
|
|
|
13
|
8041
|
100
|
|
|
|
24411
|
unshift @args, "metaclass" if @args % 2 == 1; |
14
|
8041
|
|
|
|
|
14685
|
my %options = @args; |
15
|
|
|
|
|
|
|
|
16
|
8041
|
100
|
|
|
|
19076
|
my $meta_name = exists $options{meta_name} ? $options{meta_name} : 'meta'; |
17
|
8041
|
|
|
|
|
12119
|
my $metaclass = delete $options{metaclass}; |
18
|
|
|
|
|
|
|
|
19
|
8041
|
100
|
|
|
|
14780
|
unless ( defined $metaclass ) { |
20
|
7622
|
|
|
|
|
10510
|
$metaclass = "Class::MOP::Class"; |
21
|
|
|
|
|
|
|
} else { |
22
|
419
|
|
|
|
|
1652
|
use_package_optimistically($metaclass); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
8041
|
100
|
|
|
|
72792
|
($metaclass->isa('Class::MOP::Class')) |
26
|
|
|
|
|
|
|
|| die use_module('Moose::Exception::MetaclassMustBeDerivedFromClassMOPClass')->new( class_name => $metaclass ); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# make sure the custom metaclasses get loaded |
29
|
8039
|
|
|
|
|
21725
|
foreach my $key (grep { /_(?:meta)?class$/ } keys %options) { |
|
43
|
|
|
|
|
216
|
|
30
|
38
|
50
|
|
|
|
2874
|
unless ( ref( my $class = $options{$key} ) ) { |
31
|
38
|
|
|
|
|
95
|
use_package_optimistically($class) |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
8039
|
|
|
|
|
19359
|
my $package = caller(); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# create a meta object so we can install &meta |
38
|
8039
|
|
|
|
|
25912
|
my $meta = $metaclass->initialize($package => %options); |
39
|
8036
|
100
|
|
|
|
36323
|
$meta->_add_meta_method($meta_name) |
40
|
|
|
|
|
|
|
if defined $meta_name; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# ABSTRACT: a pragma for installing and using Class::MOP metaclasses |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
__END__ |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=pod |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=encoding UTF-8 |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 NAME |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
metaclass - a pragma for installing and using Class::MOP metaclasses |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 VERSION |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
version 2.2203 |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 SYNOPSIS |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
package MyClass; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# use Class::MOP::Class |
66
|
|
|
|
|
|
|
use metaclass; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# ... or use a custom metaclass |
69
|
|
|
|
|
|
|
use metaclass 'MyMetaClass'; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# ... or use a custom metaclass |
72
|
|
|
|
|
|
|
# and custom attribute and method |
73
|
|
|
|
|
|
|
# metaclasses |
74
|
|
|
|
|
|
|
use metaclass 'MyMetaClass' => ( |
75
|
|
|
|
|
|
|
'attribute_metaclass' => 'MyAttributeMetaClass', |
76
|
|
|
|
|
|
|
'method_metaclass' => 'MyMethodMetaClass', |
77
|
|
|
|
|
|
|
); |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# ... or just specify custom attribute |
80
|
|
|
|
|
|
|
# and method classes, and Class::MOP::Class |
81
|
|
|
|
|
|
|
# is the assumed metaclass |
82
|
|
|
|
|
|
|
use metaclass ( |
83
|
|
|
|
|
|
|
'attribute_metaclass' => 'MyAttributeMetaClass', |
84
|
|
|
|
|
|
|
'method_metaclass' => 'MyMethodMetaClass', |
85
|
|
|
|
|
|
|
); |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# if we'd rather not install a 'meta' method, we can do this |
88
|
|
|
|
|
|
|
use metaclass meta_name => undef; |
89
|
|
|
|
|
|
|
# or if we'd like it to have a different name, |
90
|
|
|
|
|
|
|
use metaclass meta_name => 'my_meta'; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 DESCRIPTION |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
This is a pragma to make it easier to use a specific metaclass |
95
|
|
|
|
|
|
|
and a set of custom attribute and method metaclasses. It also |
96
|
|
|
|
|
|
|
installs a C<meta> method to your class as well, unless C<undef> |
97
|
|
|
|
|
|
|
is passed to the C<meta_name> option. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Note that if you are using Moose, you most likely do B<not> want |
100
|
|
|
|
|
|
|
to be using this - look into L<Moose::Util::MetaRole> instead. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 AUTHORS |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=over 4 |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=item * |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Stevan Little <stevan@cpan.org> |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=item * |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Dave Rolsky <autarch@urth.org> |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=item * |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Jesse Luehrs <doy@cpan.org> |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=item * |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Shawn M Moore <sartak@cpan.org> |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=item * |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org> |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=item * |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Karen Etheridge <ether@cpan.org> |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=item * |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Florian Ragwitz <rafl@debian.org> |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=item * |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Hans Dieter Pearcey <hdp@cpan.org> |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=item * |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Chris Prather <chris@prather.org> |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=item * |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Matt S Trout <mstrout@cpan.org> |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=back |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
This software is copyright (c) 2006 by Infinity Interactive, Inc. |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
153
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=cut |