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