« blib/lib/Class/MOP/Method/Meta.pm
↑ Summary
blib/lib/Moose/Exception/RequiredMethodsImportedByClass.pm »
| 1 | package Moose::Exception::MethodNameConflictInRoles; | ||||||||||
| 2 | 7 | our $VERSION = '2.4001'; | |||||||||
| 3 | |||||||||||
| 4 | 7 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 7 | extends 'Moose::Exception'; | |||||||||
| 6 | 7 | with 'Moose::Exception::Role::Class'; | |||||||||
| 7 | |||||||||||
| 8 | 7 | 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 | 10 | ▶ | sub _get_method_names { | ||||||||
|
Subroutine
_get_method_names: called CC=2 SCAR=6.9
| |||||||||||
| 20 | 10 | my $self = shift; | |||||||||
| 21 | |||||||||||
| 22 | return ( $self->conflict_methods_count == 1 ? | ||||||||||
| 23 | "'".$self->get_method_at(0)->name."'": | ||||||||||
| 24 | 10 | ▶ | Moose::Util::english_list( map { q{'} . $_->name . q{'} } $self->get_all_methods ) ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | 10 | ▶ | sub _build_message { | ||||||||
|
Subroutine
_build_message: called CC=2 SCAR=6.9
| |||||||||||
| 28 | 10 | my $self = shift; | |||||||||
| 29 | 10 | my $count = $self->conflict_methods_count; | |||||||||
| 30 | 10 | my $roles = $self->get_method_at(0)->roles_as_english_list; | |||||||||
| 31 | |||||||||||
| 32 | 10 | ▶ | if( $count == 1 ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | { | ||||||||||
| 34 | 8 | "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 | "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 | 7 | __PACKAGE__->meta->make_immutable; | |||||||||
| 47 | 7 | 1; | |||||||||