File Coverage

blib/lib/Data/Validator/Role/SmartSequenced.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1             package Data::Validator::Role::SmartSequenced;
2 1     1   2578 use Mouse::Role;
  1         28635  
  1         9  
3 1     1   789 use Mouse::Util::TypeConstraints ();
  1         3  
  1         906  
4              
5             around initialize => sub {
6             shift; # original method; not used
7             my $self = shift;
8              
9             my %args;
10             if( @_ and Mouse::Util::TypeConstraints::HashRef($_[-1])
11             and keys %{ $_[-1] } == grep { exists $_[-1]->{ $_->{name} } } @{ $self->rules } )
12             {
13             %args = %{ pop @_ };
14             }
15              
16             my $rules = $self->rules;
17             foreach my $i( 0 .. (@_ - 1) ) {
18             my $rule = $rules->[$i] || +{ name => "[$i]" };
19             $args{ $rule->{name} } = $_[$i];
20             }
21              
22             return \%args;
23             };
24              
25 1     1   11 no Mouse::Role;
  1         2  
  1         39  
26             1;
27             __END__