File Coverage

blib/lib/Validator/Custom/Constraints.pm
Criterion Covered Total %
statement 11 11 100.0
branch 2 4 50.0
condition 1 3 33.3
subroutine 3 4 75.0
pod n/a
total 17 22 77.2


line stmt bran cond sub pod time code
1             # Version 0 module
2             package Validator::Custom::Constraints;
3 5     5   15 use Object::Simple -base;
  5         14  
  5         24  
4              
5 5     5   298 use Scalar::Util;
  5         6  
  5         813  
6              
7             has 'constraints';
8              
9             sub AUTOLOAD {
10 5     5   34 my $self = shift;
11              
12 5         20 my ($package, $method) = split /::(\w+)$/, our $AUTOLOAD;
13 5 50 33     39 Carp::croak "Undefined subroutine &${package}::$method called"
14             unless Scalar::Util::blessed $self && $self->isa(__PACKAGE__);
15              
16             # Call helper with current controller
17             Carp::croak qq{Can't locate object method "$method" via package "$package"}
18 5 50       70 unless my $helper = $self->constraints->{$method};
19 5         32 return $helper->(@_);
20             }
21              
22       0     sub DESTROY { }
23              
24             1;
25              
26             =head1 NAME
27              
28             Validator::Custom::Constraints - Constraint autoloading system