line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooseX::MethodAttributes::Role; |
2
|
|
|
|
|
|
|
# ABSTRACT: code attribute introspection |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.30'; |
5
|
|
|
|
|
|
|
|
6
|
21
|
|
|
21
|
|
1378
|
use Moose (); |
|
21
|
|
|
|
|
456625
|
|
|
21
|
|
|
|
|
469
|
|
7
|
21
|
|
|
21
|
|
107
|
use Moose::Exporter; |
|
21
|
|
|
|
|
36
|
|
|
21
|
|
|
|
|
145
|
|
8
|
21
|
|
|
21
|
|
720
|
use Moose::Util::MetaRole; |
|
21
|
|
|
|
|
34
|
|
|
21
|
|
|
|
|
531
|
|
9
|
21
|
|
|
21
|
|
103
|
use Moose::Util qw/find_meta does_role ensure_all_roles/; |
|
21
|
|
|
|
|
36
|
|
|
21
|
|
|
|
|
128
|
|
10
|
|
|
|
|
|
|
# Ensure trait is registered |
11
|
21
|
|
|
21
|
|
8174
|
use MooseX::MethodAttributes::Role::Meta::Role (); |
|
21
|
|
|
|
|
41
|
|
|
21
|
|
|
|
|
416
|
|
12
|
21
|
|
|
21
|
|
10159
|
use namespace::autoclean; |
|
21
|
|
|
|
|
113059
|
|
|
21
|
|
|
|
|
112
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
#pod =head1 SYNOPSIS |
15
|
|
|
|
|
|
|
#pod |
16
|
|
|
|
|
|
|
#pod package MyRole; |
17
|
|
|
|
|
|
|
#pod use MooseX::MethodAttributes::Role; |
18
|
|
|
|
|
|
|
#pod |
19
|
|
|
|
|
|
|
#pod sub foo : Bar Baz('corge') { ... } |
20
|
|
|
|
|
|
|
#pod |
21
|
|
|
|
|
|
|
#pod my $attrs = MyRole->meta->get_method('foo')->attributes; # ["Bar", "Baz('corge')"] |
22
|
|
|
|
|
|
|
#pod |
23
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
24
|
|
|
|
|
|
|
#pod |
25
|
|
|
|
|
|
|
#pod This module allows you to write a Moose Role with code attributes of methods to |
26
|
|
|
|
|
|
|
#pod be introspected using Moose meta method objects. |
27
|
|
|
|
|
|
|
#pod |
28
|
|
|
|
|
|
|
#pod =begin Pod::Coverage |
29
|
|
|
|
|
|
|
#pod |
30
|
|
|
|
|
|
|
#pod init_meta |
31
|
|
|
|
|
|
|
#pod |
32
|
|
|
|
|
|
|
#pod =end Pod::Coverage |
33
|
|
|
|
|
|
|
#pod |
34
|
|
|
|
|
|
|
#pod =cut |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Moose::Exporter->setup_import_methods( also => 'Moose::Role' ); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub init_meta { |
39
|
10
|
|
|
10
|
0
|
22686
|
my ($class, %options) = @_; |
40
|
|
|
|
|
|
|
|
41
|
10
|
|
|
|
|
28
|
my $for_class = $options{for_class}; |
42
|
10
|
|
|
|
|
106
|
my $meta = find_meta($for_class); |
43
|
|
|
|
|
|
|
|
44
|
10
|
100
|
100
|
|
|
139
|
return $meta if $meta |
45
|
|
|
|
|
|
|
&& does_role($meta, 'MooseX::MethodAttributes::Role::Meta::Role'); |
46
|
|
|
|
|
|
|
|
47
|
9
|
100
|
|
|
|
175
|
$meta = Moose::Meta::Role->create( $for_class ) |
48
|
|
|
|
|
|
|
unless $meta; |
49
|
|
|
|
|
|
|
|
50
|
9
|
|
|
|
|
7606
|
$meta = Moose::Util::MetaRole::apply_metaroles( |
51
|
|
|
|
|
|
|
for => $meta->name, |
52
|
|
|
|
|
|
|
role_metaroles => { |
53
|
|
|
|
|
|
|
role => ['MooseX::MethodAttributes::Role::Meta::Role'], |
54
|
|
|
|
|
|
|
}, |
55
|
|
|
|
|
|
|
); |
56
|
|
|
|
|
|
|
|
57
|
9
|
|
|
|
|
5528
|
ensure_all_roles($meta->name, |
58
|
|
|
|
|
|
|
'MooseX::MethodAttributes::Role::AttrContainer', |
59
|
|
|
|
|
|
|
); |
60
|
|
|
|
|
|
|
|
61
|
9
|
|
|
|
|
2169
|
return $meta; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__END__ |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=pod |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=encoding UTF-8 |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 NAME |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
MooseX::MethodAttributes::Role - code attribute introspection |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 VERSION |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
version 0.30 |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 SYNOPSIS |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
package MyRole; |
83
|
|
|
|
|
|
|
use MooseX::MethodAttributes::Role; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub foo : Bar Baz('corge') { ... } |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
my $attrs = MyRole->meta->get_method('foo')->attributes; # ["Bar", "Baz('corge')"] |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 DESCRIPTION |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
This module allows you to write a Moose Role with code attributes of methods to |
92
|
|
|
|
|
|
|
be introspected using Moose meta method objects. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=for Pod::Coverage init_meta |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 AUTHORS |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=over 4 |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=item * |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Florian Ragwitz <rafl@debian.org> |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item * |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Tomas Doran <bobtfish@bobtfish.net> |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=back |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
This software is copyright (c) 2009 by Florian Ragwitz. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
115
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=cut |