Commit | Line | Data |
8013ebe8 |
1 | package Perl::Critic::Utils::Moose; |
8a69e820 |
2 | use strict; |
3 | use warnings; |
7b3c959c |
4 | use Sub::Exporter -setup => { |
5 | exports => ['meta_type'], |
6 | }; |
8a69e820 |
7 | |
8 | my @types = ( |
44a087cd |
9 | [ 'Moose::Meta::Role' => 'role' ], |
10 | [ 'Moose::Meta::TypeCoercion' => 'type coercion' ], |
11 | [ 'Moose::Meta::TypeConstraint' => 'type constraint' ], |
12 | [ 'Moose::Meta::Role::Application' => 'role application' ], |
8a69e820 |
13 | |
44a087cd |
14 | [ 'Class::MOP::Method' => 'method' ], |
15 | [ 'Class::MOP::Attribute' => 'attribute' ], |
16 | [ 'Class::MOP::Class' => 'class' ], |
17 | [ 'Class::MOP::Module' => 'module' ], |
18 | [ 'Class::MOP::Package' => 'package' ], |
8a69e820 |
19 | ); |
20 | |
21 | sub meta_type { |
22 | my $meta = shift; |
23 | |
24 | for (@types) { |
25 | my ($class, $name) = @$_; |
26 | return $name if $meta->isa($class); |
27 | } |
28 | |
29 | return undef; |
30 | } |
31 | |
32 | 1; |
33 | |