File Coverage

blib/lib/Moose/Exception/InvalidArgumentToMethod.pm
Criterion Covered Total %
statement 9 9 100.0
branch 4 4 100.0
condition n/a
subroutine 2 2 100.0
pod n/a
total 15 15 100.0


line stmt bran cond sub pod time code
1             package Moose::Exception::InvalidArgumentToMethod;
2             our $VERSION = '2.2205';
3              
4 8     8   6305 use Moose;
  8         21  
  8         70  
5             extends 'Moose::Exception';
6              
7             has 'argument' => (
8             is => 'ro',
9             isa => 'Any',
10             required => 1
11             );
12              
13             has [qw(type type_of_argument method_name)] => (
14             is => 'ro',
15             isa => 'Str',
16             required => 1
17             );
18              
19             has 'ordinal' => (
20             is => 'ro',
21             isa => 'Str',
22             predicate => 'is_ordinal_set'
23             );
24              
25             has 'argument_noun' => (
26             is => 'ro',
27             isa => 'Str',
28             default => 'argument'
29             );
30              
31             sub _build_message {
32 272     272   497 my $self = shift;
33 272 100       9015 my $article = ( $self->type_of_argument =~ /^[aeiou]/ ? 'an ' : 'a ');
34 272         8833 my $arg_noun = $self->argument_noun;
35              
36 272 100       9716 if( $self->is_ordinal_set ) {
37 90         2807 "The ".$self->ordinal." $arg_noun passed to ".$self->method_name." must be ".$article.$self->type_of_argument;
38             }
39             else {
40 182         6752 "The $arg_noun passed to ".$self->method_name." must be ".$article.$self->type_of_argument;
41             }
42             }
43              
44             __PACKAGE__->meta->make_immutable;
45             1;