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