1package MooseX::MethodAttributes::Role::Meta::Map;
2# ABSTRACT: generic role for storing code attributes used by classes and roles with attributes
3
4our $VERSION = '0.32';
5
6use Moose::Role;
7
8use namespace::autoclean;
9
10has _method_attribute_map => (
11    is        => 'ro',
12    isa       => 'HashRef[ArrayRef[Str]]',
13    lazy      => 1,
14    default   => sub { +{} },
15);
16
17has _method_attribute_list => (
18    is      => 'ro',
19    isa     => 'ArrayRef[Int]',
20    lazy    => 1,
21    default => sub { [] },
22);
23
24#pod =method register_method_attributes ($code, $attrs)
25#pod
26#pod Register a list of attributes for a code reference.
27#pod
28#pod =cut
29
30sub register_method_attributes {
31    my ($self, $code, $attrs) = @_;
32    push @{ $self->_method_attribute_list }, 0 + $code;
33    $self->_method_attribute_map->{ 0 + $code } = $attrs;
34    return;
35}
36
37#pod =method get_method_attributes ($code)
38#pod
39#pod Get a list of attributes associated with a coderef.
40#pod
41#pod =cut
42
43sub get_method_attributes {
44    my ($self, $code) = @_;
45    return $self->_method_attribute_map->{ 0 + $code } || [];
46}
47
481;
49
50__END__
51
52=pod
53
54=encoding UTF-8
55
56=head1 NAME
57
58MooseX::MethodAttributes::Role::Meta::Map - generic role for storing code attributes used by classes and roles with attributes
59
60=head1 VERSION
61
62version 0.32
63
64=head1 METHODS
65
66=head2 register_method_attributes ($code, $attrs)
67
68Register a list of attributes for a code reference.
69
70=head2 get_method_attributes ($code)
71
72Get a list of attributes associated with a coderef.
73
74=head1 SUPPORT
75
76Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-MethodAttributes>
77(or L<bug-MooseX-MethodAttributes@rt.cpan.org|mailto:bug-MooseX-MethodAttributes@rt.cpan.org>).
78
79There is also a mailing list available for users of this distribution, at
80L<http://lists.perl.org/list/moose.html>.
81
82There is also an irc channel available for users of this distribution, at
83L<C<#moose> on C<irc.perl.org>|irc://irc.perl.org/#moose>.
84
85=head1 AUTHORS
86
87=over 4
88
89=item *
90
91Florian Ragwitz <rafl@debian.org>
92
93=item *
94
95Tomas Doran <bobtfish@bobtfish.net>
96
97=back
98
99=head1 COPYRIGHT AND LICENCE
100
101This software is copyright (c) 2009 by Florian Ragwitz.
102
103This is free software; you can redistribute it and/or modify it under
104the same terms as the Perl 5 programming language system itself.
105
106=cut
107