« blib/lib/Moose/Exception/AttributeIsRequired.pm
↑ Summary
blib/lib/Moose/Exception/MethodExpectsFewerArgs.pm »
| 1 | package Moose::Exception::InvalidArgumentToMethod; | ||||||||||
| 2 | 8 | our $VERSION = '2.4001'; | |||||||||
| 3 | |||||||||||
| 4 | 8 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 8 | extends 'Moose::Exception'; | |||||||||
| 6 | |||||||||||
| 7 | 8 | has 'argument' => ( | |||||||||
| 8 | is => 'ro', | ||||||||||
| 9 | isa => 'Any', | ||||||||||
| 10 | required => 1 | ||||||||||
| 11 | ); | ||||||||||
| 12 | |||||||||||
| 13 | 8 | has [qw(type type_of_argument method_name)] => ( | |||||||||
| 14 | is => 'ro', | ||||||||||
| 15 | isa => 'Str', | ||||||||||
| 16 | required => 1 | ||||||||||
| 17 | ); | ||||||||||
| 18 | |||||||||||
| 19 | 8 | has 'ordinal' => ( | |||||||||
| 20 | is => 'ro', | ||||||||||
| 21 | isa => 'Str', | ||||||||||
| 22 | predicate => 'is_ordinal_set' | ||||||||||
| 23 | ); | ||||||||||
| 24 | |||||||||||
| 25 | 8 | has 'argument_noun' => ( | |||||||||
| 26 | is => 'ro', | ||||||||||
| 27 | isa => 'Str', | ||||||||||
| 28 | default => 'argument' | ||||||||||
| 29 | ); | ||||||||||
| 30 | |||||||||||
| 31 | 272 | ▶ | sub _build_message { | ||||||||
|
Subroutine
_build_message: called CC=3 SCAR=11.0
| |||||||||||
| 32 | 272 | my $self = shift; | |||||||||
| 33 | 272 | ▶ | my $article = ( $self->type_of_argument =~ /^[aeiou]/ ? 'an ' : 'a '); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | 272 | my $arg_noun = $self->argument_noun; | |||||||||
| 35 | |||||||||||
| 36 | 272 | ▶ | if( $self->is_ordinal_set ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 37 | 90 | "The ".$self->ordinal." $arg_noun passed to ".$self->method_name." must be ".$article.$self->type_of_argument; | |||||||||
| 38 | } | ||||||||||
| 39 | else { | ||||||||||
| 40 | 182 | "The $arg_noun passed to ".$self->method_name." must be ".$article.$self->type_of_argument; | |||||||||
| 41 | } | ||||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | 8 | __PACKAGE__->meta->make_immutable; | |||||||||
| 45 | 8 | 1; | |||||||||