File Coverage

blib/lib/MooseX/MethodAttributes/Role/Meta/Map.pm
Criterion Covered Total %
statement 13 13 100.0
branch n/a
condition 2 2 100.0
subroutine 4 4 100.0
pod 2 2 100.0
total 21 21 100.0


line stmt bran cond sub pod time code
1             package MooseX::MethodAttributes::Role::Meta::Map;
2             # ABSTRACT: generic role for storing code attributes used by classes and roles with attributes
3              
4             our $VERSION = '0.32';
5              
6 21     21   14380 use Moose::Role;
  21         55  
  21         157  
7              
8 21     21   114533 use namespace::autoclean;
  21         119  
  21         211  
9              
10             has _method_attribute_map => (
11             is => 'ro',
12             isa => 'HashRef[ArrayRef[Str]]',
13             lazy => 1,
14             default => sub { +{} },
15             );
16              
17             has _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              
30             sub register_method_attributes {
31 62     62 1 871 my ($self, $code, $attrs) = @_;
32 62         224 push @{ $self->_method_attribute_list }, 0 + $code;
  62         2699  
33 62         2355 $self->_method_attribute_map->{ 0 + $code } = $attrs;
34 62         173 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              
43             sub get_method_attributes {
44 35     35 1 10522 my ($self, $code) = @_;
45 35   100     1353 return $self->_method_attribute_map->{ 0 + $code } || [];
46             }
47              
48             1;
49              
50             __END__
51              
52             =pod
53              
54             =encoding UTF-8
55              
56             =head1 NAME
57              
58             MooseX::MethodAttributes::Role::Meta::Map - generic role for storing code attributes used by classes and roles with attributes
59              
60             =head1 VERSION
61              
62             version 0.32
63              
64             =head1 METHODS
65              
66             =head2 register_method_attributes ($code, $attrs)
67              
68             Register a list of attributes for a code reference.
69              
70             =head2 get_method_attributes ($code)
71              
72             Get a list of attributes associated with a coderef.
73              
74             =head1 SUPPORT
75              
76             Bugs 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              
79             There is also a mailing list available for users of this distribution, at
80             L<http://lists.perl.org/list/moose.html>.
81              
82             There is also an irc channel available for users of this distribution, at
83             L<C<#moose> on C<irc.perl.org>|irc://irc.perl.org/#moose>.
84              
85             =head1 AUTHORS
86              
87             =over 4
88              
89             =item *
90              
91             Florian Ragwitz <rafl@debian.org>
92              
93             =item *
94              
95             Tomas Doran <bobtfish@bobtfish.net>
96              
97             =back
98              
99             =head1 COPYRIGHT AND LICENCE
100              
101             This software is copyright (c) 2009 by Florian Ragwitz.
102              
103             This is free software; you can redistribute it and/or modify it under
104             the same terms as the Perl 5 programming language system itself.
105              
106             =cut