File Coverage

blib/lib/Moose/Exception/OverloadConflictInSummation.pm
Criterion Covered Total %
statement 13 18 72.2
branch 2 2 100.0
condition n/a
subroutine 3 4 75.0
pod 0 1 0.0
total 18 25 72.0


line stmt bran cond sub pod time code
1             package Moose::Exception::OverloadConflictInSummation;
2             our $VERSION = '2.2205';
3              
4 1     1   569 use Moose;
  1         3  
  1         9  
5             extends 'Moose::Exception';
6              
7 1     1   7 use Moose::Util 'find_meta';
  1         2  
  1         11  
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 =>
24             "This attribute is an ArrayRef containing role names, if you want metaobjects\n"
25             . "associated with these role names, then call method roles on the exception object.\n",
26             );
27              
28             has 'overloaded_op' => (
29             is => 'ro',
30             isa => 'Str',
31             required => 1,
32             );
33              
34             sub roles {
35 0     0 0 0 my $self = shift;
36 0         0 my @role_names = $self->role_names;
37 0         0 my @roles = map { find_meta($_) } @role_names;
  0         0  
38 0         0 return @roles;
39             }
40              
41             sub _build_message {
42 6     6   12 my $self = shift;
43              
44 6         256 my @roles = $self->role_names;
45 6         28 my $role_names = join "|", @roles;
46              
47 6         204 my $op = $self->overloaded_op;
48 6 100       19 if ( $op eq 'fallback' ) {
49             return
50 2         49 'We have encountered an overloading conflict for the fallback '
51             . 'during composition. This is a fatal error.';
52             }
53             else {
54             return
55 4         109 "Role '$role_names' has encountered an overloading conflict "
56             . "during composition. The two roles both overload the '$op' operator. "
57             . 'This is a fatal error.';
58             }
59             }
60              
61             __PACKAGE__->meta->make_immutable;
62             1;