File Coverage

blib/lib/Moose/Exception/OverrideConflictInSummation.pm
Criterion Covered Total %
statement 12 17 70.5
branch 2 2 100.0
condition n/a
subroutine 3 4 75.0
pod 0 1 0.0
total 17 24 70.8


line stmt bran cond sub pod time code
1             package Moose::Exception::OverrideConflictInSummation;
2             our $VERSION = '2.2203';
3              
4 3     3   1859 use Moose;
  3         7  
  3         24  
5             extends 'Moose::Exception';
6              
7 3     3   25 use Moose::Util 'find_meta';
  3         6  
  3         24  
8              
9             has 'role_application' => (
10             is => 'ro',
11             isa => 'Moose::Meta::Role::Application::RoleSummation',
12             required => 1
13             );
14              
15             has 'role_names' => (
16             traits => ['Array'],
17             is => 'bare',
18             isa => 'ArrayRef[Str]',
19             handles => {
20             role_names => 'elements',
21             },
22             required => 1,
23             documentation => "This attribute is an ArrayRef containing role names, if you want metaobjects\n".
24             "associated with these role names, then call method roles on the exception object.\n",
25             );
26              
27             has 'method_name' => (
28             is => 'ro',
29             isa => 'Str',
30             required => 1
31             );
32              
33             has 'two_overrides_found' => (
34             is => 'ro',
35             isa => 'Bool',
36             required => 1,
37             default => 0
38             );
39              
40             sub roles {
41 0     0 0 0 my $self = shift;
42 0         0 my @role_names = $self->role_names;
43 0         0 my @roles = map { find_meta($_) } @role_names;
  0         0  
44 0         0 return @roles;
45             }
46              
47             sub _build_message {
48 7     7   19 my $self = shift;
49              
50 7         277 my @roles = $self->role_names;
51 7         25 my $role_names = join "|", @roles;
52              
53 7 100       266 if( $self->two_overrides_found ) {
54 4         100 return "We have encountered an 'override' method conflict ".
55             "during composition (Two 'override' methods of the same name encountered). ".
56             "This is a fatal error.";
57             }
58             else {
59 3         104 return "Role '$role_names' has encountered an 'override' method conflict " .
60             "during composition (A local method of the same name has been found). This " .
61             "is a fatal error." ;
62             }
63             }
64              
65             __PACKAGE__->meta->make_immutable;
66             1;