File Coverage

blib/lib/Enbld/Target/AttributeExtension/RegEx.pm
Criterion Covered Total %
statement 22 22 100.0
branch 2 2 100.0
condition n/a
subroutine 5 5 100.0
pod 0 1 0.0
total 29 30 96.6


line stmt bran cond sub pod time code
1             package Enbld::Target::AttributeExtension::RegEx;
2              
3 7     7   3200 use strict;
  7         11  
  7         241  
4 7     7   28 use warnings;
  7         9  
  7         144  
5              
6 7     7   28 use Carp;
  7         8  
  7         470  
7              
8 7     7   37 use parent qw/Enbld::Target::Attribute/;
  7         8  
  7         38  
9              
10             sub validate {
11 273     273 0 341 my ( $self, $string ) = @_;
12              
13 273         665 $self->SUPER::validate( $string );
14              
15 269         394 eval { "" =~ /$string/ };
  269         1640  
16              
17 269 100       602 if ( $@ ) {
18 2         4 my $type = ref( $self );
19 2         8 $type =~ s/.*:://;
20              
21 2         10 require Enbld::Exception;
22 2         10 croak( Enbld::Exception->new(
23             "Attribute '$type' is NOT valid regular expression string",
24             $string
25             ) );
26             }
27              
28 267         475 return $string;
29             }
30              
31             1;