Add built local::lib
[catagits/Gitalist.git] / local-lib5 / lib / perl5 / MooseX / MethodAttributes / Role.pm
CommitLineData
3fea05b9 1use strict;
2use warnings;
3
4package MooseX::MethodAttributes::Role;
5our $VERSION = '0.18';
6
7# ABSTRACT: code attribute introspection
8
9use Moose ();
10use Moose::Exporter;
11use Moose::Util::MetaRole;
12use Moose::Util qw/find_meta does_role ensure_all_roles/;
13# Ensure trait is registered
14use MooseX::MethodAttributes::Role::Meta::Role ();
15
16
17Moose::Exporter->setup_import_methods( also => 'Moose::Role' );
18
19sub init_meta {
20 my ($class, %options) = @_;
21
22 my $for_class = $options{for_class};
23 my $meta = find_meta($for_class);
24
25 return $meta if $meta
26 && does_role($meta, 'MooseX::MethodAttributes::Role::Meta::Role');
27
28 $meta = Moose::Meta::Role->initialize( $for_class )
29 unless $meta;
30
31 $meta = Moose::Util::MetaRole::apply_metaclass_roles(
32 for_class => $meta->name,
33 metaclass_roles => [ 'MooseX::MethodAttributes::Role::Meta::Role' ],
34 );
35
36 ensure_all_roles($meta->name,
37 'MooseX::MethodAttributes::Role::AttrContainer',
38 );
39
40 return $meta;
41}
42
431;
44
45__END__
46
47=pod
48
49=head1 NAME
50
51MooseX::MethodAttributes::Role - code attribute introspection
52
53=head1 VERSION
54
55version 0.18
56
57=head1 SYNOPSIS
58
59 package MyRole;
60 use MooseX::MethodAttributes::Role;
61
62 sub foo : Bar Baz('corge') { ... }
63
64 my $attrs = MyRole->meta->get_method('foo')->attributes; # ["Bar", "Baz('corge')"]
65
66=head1 DESCRIPTION
67
68This module allows you to write a Moose Role with code attributes of methods to
69be introspected using Moose meta method objects.
70
71=begin Pod::Coverage
72
73init_meta
74
75=end Pod::Coverage
76
77
78
79=head1 AUTHORS
80
81 Florian Ragwitz <rafl@debian.org>
82 Tomas Doran <bobtfish@bobtfish.net>
83
84=head1 COPYRIGHT AND LICENSE
85
86This software is copyright (c) 2009 by Florian Ragwitz.
87
88This is free software; you can redistribute it and/or modify it under
89the same terms as perl itself.
90
91=cut
92
93