File Coverage

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