File Coverage

blib/lib/Moose/Exception/RequiredMethodsImportedByClass.pm
Criterion Covered Total %
statement 10 10 100.0
branch 1 2 50.0
condition n/a
subroutine 2 2 100.0
pod n/a
total 13 14 92.8


line stmt bran cond sub pod time code
1             package Moose::Exception::RequiredMethodsImportedByClass;
2             our $VERSION = '2.2206';
3              
4 2     2   1335 use Moose;
  2         7  
  2         15  
5             extends 'Moose::Exception';
6             with 'Moose::Exception::Role::Class', 'Moose::Exception::Role::Role';
7              
8             has 'missing_methods' => (
9             traits => ['Array'],
10             is => 'ro',
11             isa => 'ArrayRef[Moose::Meta::Role::Method::Required]',
12             handles => { method_count => 'count',
13             get_method_at => 'get',
14             get_all_methods => 'elements',
15             },
16             required => 1
17             );
18              
19             has 'imported_method' => (
20             is => 'ro',
21             isa => 'Moose::Meta::Role::Method::Required',
22             required => 1
23             );
24              
25             sub _build_message {
26 2     2   7 my $self = shift;
27              
28 2 50       93 my $noun = $self->method_count == 1 ? 'method' : 'methods';
29 2         95 my $list = Moose::Util::english_list( map { q{'} . $_ . q{'} } $self->get_all_methods );
  2         13  
30              
31 2         88 my ($class, $role, $method) = ($self->class_name,
32             $self->role_name,
33             $self->imported_method);
34              
35 2         12 my ($class_quoted, $role_quoted) = ("'".$class."'","'".$role."'");
36              
37 2         18 "$role_quoted requires the $noun $list "
38             . "to be implemented by $class_quoted. "
39             . "If you imported functions intending to use them as "
40             . "methods, you need to explicitly mark them as such, via "
41             . "$class->meta->add_method($method"
42             . " => \\&$method)";
43             }
44              
45             __PACKAGE__->meta->make_immutable;
46             1;