3ac2c21317ad72a7c0ece9da443d82185b3c66a7
[catagits/Gitalist.git] / local-lib5 / lib / perl5 / MooseX / MethodAttributes / Role / Meta / Map.pm
1 package MooseX::MethodAttributes::Role::Meta::Map;
2 our $VERSION = '0.18';
3
4 # ABSTRACT: generic role for storing code attributes used by classes and roles with attributes
5
6 use Moose::Role;
7 use MooseX::Types::Moose qw/HashRef ArrayRef Str Int/;
8
9 use namespace::clean -except => 'meta';
10
11 has _method_attribute_map => (
12     is        => 'ro',
13     isa       => HashRef[ArrayRef[Str]],
14     lazy      => 1,
15     default   => sub { +{} },
16 );
17
18 has _method_attribute_list => (
19     is      => 'ro',
20     isa     => ArrayRef[Int],
21     lazy    => 1,
22     default => sub { [] },
23 );
24
25
26 sub register_method_attributes {
27     my ($self, $code, $attrs) = @_;
28     push @{ $self->_method_attribute_list }, 0 + $code;
29     $self->_method_attribute_map->{ 0 + $code } = $attrs;
30     return;
31 }
32
33
34 sub get_method_attributes {
35     my ($self, $code) = @_;
36     return $self->_method_attribute_map->{ 0 + $code } || [];
37 }
38
39 1;
40
41
42 __END__
43
44 =pod
45
46 =head1 NAME
47
48 MooseX::MethodAttributes::Role::Meta::Map - generic role for storing code attributes used by classes and roles with attributes
49
50 =head1 VERSION
51
52 version 0.18
53
54 =head1 METHODS
55
56 =head2 register_method_attributes ($code, $attrs)
57
58 Register a list of attributes for a code reference.
59
60
61
62 =head2 get_method_attributes ($code)
63
64 Get a list of attributes associated with a coderef.
65
66
67
68 =head1 AUTHORS
69
70   Florian Ragwitz <rafl@debian.org>
71   Tomas Doran <bobtfish@bobtfish.net>
72
73 =head1 COPYRIGHT AND LICENSE
74
75 This software is copyright (c) 2009 by Florian Ragwitz.
76
77 This is free software; you can redistribute it and/or modify it under
78 the same terms as perl itself.
79
80 =cut 
81
82