1 package MooseX::Declare::Syntax::MethodDeclaration;
4 use MooseX::Method::Signatures::Meta::Method;
5 use MooseX::Method::Signatures ();
6 use MooseX::Method::Signatures::Types qw/PrototypeInjections/;
8 use namespace::clean -except => 'meta';
11 MooseX::Declare::Syntax::KeywordHandling
15 register_method_declaration
18 has prototype_injections => (
20 isa => PrototypeInjections,
21 predicate => 'has_prototype_injections',
25 my ($self, $ctx) = @_;
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);
36 $args{prototype_injections} = $self->prototype_injections
37 if $self->has_prototype_injections;
39 my $mxms = MooseX::Method::Signatures->new(%args);
49 MooseX::Declare::Syntax::MethodDeclaration - Handles method declarations
53 A role for keyword handlers that gives a framework to add or modify
54 methods or things that look like methods.
60 =item * L<MooseX::Declare::Syntax::KeywordHandling>
66 =head2 prototype_injections
68 An optional structure describing additional things to be added to a methods
69 signature. A popular example is found in the C<around>
70 L<method modifier handler|MooseX::Declare::Syntax::Keyword::MethodModifier>:
74 =head1 REQUIRED METHODS
76 =head2 register_method_declaration
78 Object->register_method_declaration (Object $metaclass, Str $name, Object $method)
80 This method will be called with the target metaclass and the final built
81 L<method meta object|MooseX::Method::Signatures::Meta::Method> and its name.
82 The value it returns will be the value returned where the method was declared.
88 Object->parse (Object $ctx);
90 Reads a name and a prototype and builds the method meta object then registers
91 it into the current class using MooseX::Method::Signatures and a
92 C<custom_method_application>, that calls L</register_method_declaration>.
98 =item * L<MooseX::Declare>
100 =item * L<MooseX::Declare::Syntax::NamespaceHandling>
102 =item * L<MooseX::Declare::Syntax::MooseSetup>
104 =item * L<MooseX::Method::Signatures>
108 =head1 AUTHOR, COPYRIGHT & LICENSE
110 See L<MooseX::Declare>