File Coverage

blib/lib/Moose/Exception/MetaclassIsARoleNotASubclassOfGivenMetaclass.pm
Criterion Covered Total %
statement 11 11 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 14 14 100.0


line stmt bran cond sub pod time code
1             package Moose::Exception::MetaclassIsARoleNotASubclassOfGivenMetaclass;
2             our $VERSION = '2.2205';
3              
4 1     1   740 use Moose;
  1         10  
  1         9  
5             extends 'Moose::Exception';
6             with 'Moose::Exception::Role::Role';
7              
8 1     1   8 use Moose::Util 'find_meta';
  1         3  
  1         20  
9              
10             has 'metaclass' => (
11             is => 'ro',
12             isa => 'Str',
13             required => 1
14             );
15              
16             sub _build_message {
17 1     1   3 my $self = shift;
18 1         34 my $role_name = $self->role_name;
19 1         7 my $role = find_meta( $role_name );
20 1         43 my $metaclass = $self->metaclass;
21 1         43 return "$role_name already has a metaclass, but it does not inherit $metaclass ($role). "
22             ."You cannot make the same thing a role and a class. Remove either Moose or Moose::Role.";
23             }
24              
25             __PACKAGE__->meta->make_immutable;
26             1;