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