File Coverage

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


line stmt bran cond sub pod time code
1             package Moose::Exception::ValidationFailedForInlineTypeConstraint;
2             our $VERSION = '2.2203';
3              
4 30     30   17304 use Moose;
  30         75  
  30         217  
5             extends 'Moose::Exception';
6             with 'Moose::Exception::Role::Class';
7              
8             has 'type_constraint_message' => (
9             is => 'ro',
10             isa => 'Str',
11             required => 1
12             );
13              
14             has 'attribute_name' => (
15             is => 'ro',
16             isa => 'Str',
17             required => 1
18             );
19              
20             has 'value' => (
21             is => 'ro',
22             isa => 'Any',
23             required => 1
24             );
25              
26             has 'new_member' => (
27             is => 'ro',
28             isa => 'Bool',
29             default => 0,
30             predicate => 'is_a_new_member'
31             );
32              
33             sub _build_message {
34 1009     1009   1791 my $self = shift;
35              
36 1009         1586 my $line1;
37              
38 1009 100       30892 if( $self->new_member ) {
39 907         27026 $line1 = "A new member value for ".$self->attribute_name." does not pass its type constraint because: "
40             }
41             else {
42 102         3402 $line1 = "Attribute (".$self->attribute_name.") does not pass the type constraint because: ";
43             }
44              
45 1009         31973 return $line1 . $self->type_constraint_message;
46             }
47              
48             __PACKAGE__->meta->make_immutable;
49             1;