File Coverage

blib/lib/Moose/Exception/MethodNameConflictInRoles.pm
Criterion Covered Total %
statement 12 12 100.0
branch 4 4 100.0
condition n/a
subroutine 3 3 100.0
pod n/a
total 19 19 100.0


line stmt bran cond sub pod time code
1             package Moose::Exception::MethodNameConflictInRoles;
2             our $VERSION = '2.2203';
3              
4 7     7   4278 use Moose;
  7         17  
  7         48  
5             extends 'Moose::Exception';
6             with 'Moose::Exception::Role::Class';
7              
8             has 'conflict' => (
9             traits => ['Array'],
10             is => 'ro',
11             isa => 'ArrayRef[Moose::Meta::Role::Method::Conflicting]',
12             handles => { conflict_methods_count => 'count',
13             get_method_at => 'get',
14             get_all_methods => 'elements',
15             },
16             required => 1
17             );
18              
19             sub _get_method_names {
20 10     10   22 my $self = shift;
21              
22             return ( $self->conflict_methods_count == 1 ?
23             "'".$self->get_method_at(0)->name."'":
24 10 100       376 Moose::Util::english_list( map { q{'} . $_->name . q{'} } $self->get_all_methods ) );
  4         113  
25             }
26              
27             sub _build_message {
28 10     10   24 my $self = shift;
29 10         418 my $count = $self->conflict_methods_count;
30 10         395 my $roles = $self->get_method_at(0)->roles_as_english_list;
31              
32 10 100       47 if( $count == 1 )
33             {
34 8         58 "Due to a method name conflict in roles "
35             .$roles.", the method ".$self->_get_method_names
36             ." must be implemented or excluded by '".$self->class_name."'";
37             }
38             else
39             {
40 2         11 "Due to method name conflicts in roles "
41             .$roles.", the methods ".$self->_get_method_names
42             ." must be implemented or excluded by '".$self->class_name."'";
43             }
44             }
45              
46             __PACKAGE__->meta->make_immutable;
47             1;