Add built local::lib
[catagits/Gitalist.git] / local-lib5 / lib / perl5 / MooseX / Declare / Syntax / MethodDeclaration.pm
CommitLineData
3fea05b9 1package MooseX::Declare::Syntax::MethodDeclaration;
2
3use Moose::Role;
4use MooseX::Method::Signatures::Meta::Method;
5use MooseX::Method::Signatures ();
6use MooseX::Method::Signatures::Types qw/PrototypeInjections/;
7
8use namespace::clean -except => 'meta';
9
10with qw(
11 MooseX::Declare::Syntax::KeywordHandling
12);
13
14requires qw(
15 register_method_declaration
16);
17
18has prototype_injections => (
19 is => 'ro',
20 isa => PrototypeInjections,
21 predicate => 'has_prototype_injections',
22);
23
24sub parse {
25 my ($self, $ctx) = @_;
26
27 my %args = (
28 context => $ctx->_dd_context,
29 initialized_context => 1,
30 custom_method_application => sub {
31 my ($meta, $name, $method) = @_;
32 $self->register_method_declaration($meta, $name, $method);
33 },
34 );
35
36 $args{prototype_injections} = $self->prototype_injections
37 if $self->has_prototype_injections;
38
39 my $mxms = MooseX::Method::Signatures->new(%args);
40 $mxms->parser;
41}
42
431;
44
45__END__
46
47=head1 NAME
48
49MooseX::Declare::Syntax::MethodDeclaration - Handles method declarations
50
51=head1 DESCRIPTION
52
53A role for keyword handlers that gives a framework to add or modify
54methods or things that look like methods.
55
56=head1 CONSUMES
57
58=over
59
60=item * L<MooseX::Declare::Syntax::KeywordHandling>
61
62=back
63
64=head1 ATTRIBUTES
65
66=head2 prototype_injections
67
68An optional structure describing additional things to be added to a methods
69signature. A popular example is found in the C<around>
70L<method modifier handler|MooseX::Declare::Syntax::Keyword::MethodModifier>:
71
72
73
74=head1 REQUIRED METHODS
75
76=head2 register_method_declaration
77
78 Object->register_method_declaration (Object $metaclass, Str $name, Object $method)
79
80This method will be called with the target metaclass and the final built
81L<method meta object|MooseX::Method::Signatures::Meta::Method> and its name.
82The value it returns will be the value returned where the method was declared.
83
84=head1 METHODS
85
86=head2 parse
87
88 Object->parse (Object $ctx);
89
90Reads a name and a prototype and builds the method meta object then registers
91it into the current class using MooseX::Method::Signatures and a
92C<custom_method_application>, that calls L</register_method_declaration>.
93
94=head1 SEE ALSO
95
96=over
97
98=item * L<MooseX::Declare>
99
100=item * L<MooseX::Declare::Syntax::NamespaceHandling>
101
102=item * L<MooseX::Declare::Syntax::MooseSetup>
103
104=item * L<MooseX::Method::Signatures>
105
106=back
107
108=head1 AUTHOR, COPYRIGHT & LICENSE
109
110See L<MooseX::Declare>
111
112=cut