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   25 use Object::Simple -base;
  5         10  
  5         34  
4              
5 5     5   423 use Scalar::Util;
  5         7  
  5         1191  
6              
7             has 'constraints';
8              
9             sub AUTOLOAD {
10 5     5   45 my $self = shift;
11              
12 5         31 my ($package, $method) = split /::(\w+)$/, our $AUTOLOAD;
13 5 50 33     44 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       113 unless my $helper = $self->constraints->{$method};
19 5         45 return $helper->(@_);
20             }
21              
22       0     sub DESTROY { }
23              
24             1;
25              
26             =head1 NAME
27              
28             Validator::Custom::Constraints - Constraint autoloading system