| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package MooseX::Declare::Syntax::MethodDeclaration; |
|
2
|
|
|
|
|
|
|
# ABSTRACT: Handles method declarations |
|
3
|
|
|
|
|
|
|
$MooseX::Declare::Syntax::MethodDeclaration::VERSION = '0.40'; |
|
4
|
24
|
|
|
24
|
|
12453
|
use Moose::Role; |
|
|
24
|
|
|
|
|
43
|
|
|
|
24
|
|
|
|
|
137
|
|
|
5
|
24
|
|
|
24
|
|
105693
|
use MooseX::Method::Signatures::Meta::Method; |
|
|
24
|
|
|
|
|
22337891
|
|
|
|
24
|
|
|
|
|
1255
|
|
|
6
|
24
|
|
|
24
|
|
15468
|
use MooseX::Method::Signatures 0.36 (); |
|
|
24
|
|
|
|
|
2599571
|
|
|
|
24
|
|
|
|
|
960
|
|
|
7
|
24
|
|
|
24
|
|
250
|
use MooseX::Method::Signatures::Types qw/PrototypeInjections/; |
|
|
24
|
|
|
|
|
39
|
|
|
|
24
|
|
|
|
|
217
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
24
|
|
|
24
|
|
28518
|
use namespace::clean -except => 'meta'; |
|
|
24
|
|
|
|
|
42
|
|
|
|
24
|
|
|
|
|
183
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
|
12
|
|
|
|
|
|
|
#pod |
|
13
|
|
|
|
|
|
|
#pod A role for keyword handlers that gives a framework to add or modify |
|
14
|
|
|
|
|
|
|
#pod methods or things that look like methods. |
|
15
|
|
|
|
|
|
|
#pod |
|
16
|
|
|
|
|
|
|
#pod =head1 CONSUMES |
|
17
|
|
|
|
|
|
|
#pod |
|
18
|
|
|
|
|
|
|
#pod =for :list |
|
19
|
|
|
|
|
|
|
#pod * L<MooseX::Declare::Syntax::KeywordHandling> |
|
20
|
|
|
|
|
|
|
#pod |
|
21
|
|
|
|
|
|
|
#pod =cut |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
with qw( |
|
24
|
|
|
|
|
|
|
MooseX::Declare::Syntax::KeywordHandling |
|
25
|
|
|
|
|
|
|
); |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
#pod =head1 REQUIRED METHODS |
|
28
|
|
|
|
|
|
|
#pod |
|
29
|
|
|
|
|
|
|
#pod =head2 register_method_declaration |
|
30
|
|
|
|
|
|
|
#pod |
|
31
|
|
|
|
|
|
|
#pod Object->register_method_declaration (Object $metaclass, Str $name, Object $method) |
|
32
|
|
|
|
|
|
|
#pod |
|
33
|
|
|
|
|
|
|
#pod This method will be called with the target metaclass and the final built |
|
34
|
|
|
|
|
|
|
#pod L<method meta object|MooseX::Method::Signatures::Meta::Method> and its name. |
|
35
|
|
|
|
|
|
|
#pod The value it returns will be the value returned where the method was declared. |
|
36
|
|
|
|
|
|
|
#pod |
|
37
|
|
|
|
|
|
|
#pod =cut |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
requires qw( |
|
40
|
|
|
|
|
|
|
register_method_declaration |
|
41
|
|
|
|
|
|
|
); |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
#pod =attr prototype_injections |
|
44
|
|
|
|
|
|
|
#pod |
|
45
|
|
|
|
|
|
|
#pod An optional structure describing additional things to be added to a methods |
|
46
|
|
|
|
|
|
|
#pod signature. A popular example is found in the C<around> |
|
47
|
|
|
|
|
|
|
#pod L<method modifier handler|MooseX::Declare::Syntax::Keyword::MethodModifier>: |
|
48
|
|
|
|
|
|
|
#pod |
|
49
|
|
|
|
|
|
|
#pod =cut |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
has prototype_injections => ( |
|
52
|
|
|
|
|
|
|
is => 'ro', |
|
53
|
|
|
|
|
|
|
isa => PrototypeInjections, |
|
54
|
|
|
|
|
|
|
predicate => 'has_prototype_injections', |
|
55
|
|
|
|
|
|
|
); |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
#pod =method parse |
|
58
|
|
|
|
|
|
|
#pod |
|
59
|
|
|
|
|
|
|
#pod Object->parse (Object $ctx); |
|
60
|
|
|
|
|
|
|
#pod |
|
61
|
|
|
|
|
|
|
#pod Reads a name and a prototype and builds the method meta object then registers |
|
62
|
|
|
|
|
|
|
#pod it into the current class using MooseX::Method::Signatures and a |
|
63
|
|
|
|
|
|
|
#pod C<custom_method_application>, that calls L</register_method_declaration>. |
|
64
|
|
|
|
|
|
|
#pod |
|
65
|
|
|
|
|
|
|
#pod =cut |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub parse { |
|
68
|
51
|
|
|
51
|
1
|
101
|
my ($self, $ctx) = @_; |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
my %args = ( |
|
71
|
|
|
|
|
|
|
context => $ctx->_dd_context, |
|
72
|
|
|
|
|
|
|
initialized_context => 1, |
|
73
|
|
|
|
|
|
|
custom_method_application => sub { |
|
74
|
53
|
|
|
53
|
|
505263
|
my ($meta, $name, $method) = @_; |
|
75
|
53
|
|
|
|
|
334
|
$self->register_method_declaration($meta, $name, $method); |
|
76
|
|
|
|
|
|
|
}, |
|
77
|
51
|
|
|
|
|
1600
|
); |
|
78
|
|
|
|
|
|
|
|
|
79
|
51
|
100
|
|
|
|
2174
|
$args{prototype_injections} = $self->prototype_injections |
|
80
|
|
|
|
|
|
|
if $self->has_prototype_injections; |
|
81
|
|
|
|
|
|
|
|
|
82
|
51
|
|
|
|
|
1615
|
my $mxms = MooseX::Method::Signatures->new(%args); |
|
83
|
51
|
|
|
|
|
4002
|
$mxms->parser; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
#pod =head1 SEE ALSO |
|
87
|
|
|
|
|
|
|
#pod |
|
88
|
|
|
|
|
|
|
#pod =for :list |
|
89
|
|
|
|
|
|
|
#pod * L<MooseX::Declare> |
|
90
|
|
|
|
|
|
|
#pod * L<MooseX::Declare::Syntax::NamespaceHandling> |
|
91
|
|
|
|
|
|
|
#pod * L<MooseX::Declare::Syntax::MooseSetup> |
|
92
|
|
|
|
|
|
|
#pod * L<MooseX::Method::Signatures> |
|
93
|
|
|
|
|
|
|
#pod |
|
94
|
|
|
|
|
|
|
#pod =cut |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
1; |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
__END__ |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=pod |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=encoding UTF-8 |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 NAME |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
MooseX::Declare::Syntax::MethodDeclaration - Handles method declarations |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 VERSION |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
version 0.40 |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
A role for keyword handlers that gives a framework to add or modify |
|
115
|
|
|
|
|
|
|
methods or things that look like methods. |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head2 prototype_injections |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
An optional structure describing additional things to be added to a methods |
|
122
|
|
|
|
|
|
|
signature. A popular example is found in the C<around> |
|
123
|
|
|
|
|
|
|
L<method modifier handler|MooseX::Declare::Syntax::Keyword::MethodModifier>: |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 METHODS |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head2 parse |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Object->parse (Object $ctx); |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Reads a name and a prototype and builds the method meta object then registers |
|
132
|
|
|
|
|
|
|
it into the current class using MooseX::Method::Signatures and a |
|
133
|
|
|
|
|
|
|
C<custom_method_application>, that calls L</register_method_declaration>. |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 CONSUMES |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=over 4 |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=item * |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
L<MooseX::Declare::Syntax::KeywordHandling> |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=back |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 REQUIRED METHODS |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head2 register_method_declaration |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Object->register_method_declaration (Object $metaclass, Str $name, Object $method) |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
This method will be called with the target metaclass and the final built |
|
152
|
|
|
|
|
|
|
L<method meta object|MooseX::Method::Signatures::Meta::Method> and its name. |
|
153
|
|
|
|
|
|
|
The value it returns will be the value returned where the method was declared. |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=over 4 |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=item * |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
L<MooseX::Declare> |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=item * |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
L<MooseX::Declare::Syntax::NamespaceHandling> |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=item * |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
L<MooseX::Declare::Syntax::MooseSetup> |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=item * |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
L<MooseX::Method::Signatures> |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=back |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head1 AUTHOR |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
Florian Ragwitz <rafl@debian.org> |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
This software is copyright (c) 2008 by Florian Ragwitz. |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
186
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=cut |