Add built local::lib
[catagits/Gitalist.git] / local-lib5 / lib / perl5 / MooseX / Declare / Syntax / Keyword / MethodModifier.pm
1 package MooseX::Declare::Syntax::Keyword::MethodModifier;
2
3 use Moose;
4 use Moose::Util;
5 use Moose::Util::TypeConstraints;
6
7 use namespace::clean -except => 'meta';
8
9 with 'MooseX::Declare::Syntax::MethodDeclaration';
10
11 has modifier_type => (
12     is          => 'rw',
13     isa         => enum(undef, qw( around after before override augment )),
14     required    => 1,
15 );
16
17 sub register_method_declaration {
18     my ($self, $meta, $name, $method) = @_;
19     return Moose::Util::add_method_modifier($meta->name, $self->modifier_type, [$name, $method->body]);
20 }
21
22 1;
23
24 __END__
25
26 =head1 NAME
27
28 MooseX::Declare::Syntax::Keyword::MethodModifier - Handle method modifier declarations
29
30 =head1 DESCRIPTION
31
32 Allows the implementation of method modification handlers like C<around> and
33 C<before>.
34
35 =head1 CONSUMES
36
37 =over
38
39 =item * L<MooseX::Declare::Syntax::MethodDeclaration>
40
41 =back
42
43 =head1 ATTRIBUTES
44
45 =head2 modifier_type
46
47 A required string that is one of:
48
49   around
50   after
51   before
52   override
53   augment
54
55 =head1 METHODS
56
57 =head2 register_method_declaration
58
59   Object->register_method_declaration (Object $metaclass, Str $name, Object $method)
60
61 This will add the method modifier to the C<$metaclass> via L<Moose::Util>s
62 C<add_method_modifier>, whose return value will also be returned from this
63 method.
64
65 =head1 SEE ALSO
66
67 =over
68
69 =item * L<MooseX::Declare>
70
71 =item * L<MooseX::Declare::Syntax::MooseSetup>
72
73 =item * L<MooseX::Declare::Syntax::MethodDeclaration>
74
75 =item * L<MooseX::Method::Signatures>
76
77 =back
78
79 =head1 AUTHOR, COPYRIGHT & LICENSE
80
81 See L<MooseX::Declare>
82
83 =cut