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   4564 use strict;
  7         14  
  7         224  
4 7     7   32 use warnings;
  7         11  
  7         155  
5              
6 7     7   33 use Carp;
  7         14  
  7         402  
7              
8 7     7   33 use parent qw/Enbld::Target::Attribute/;
  7         19  
  7         36  
9              
10             sub validate {
11 273     273 0 483 my ( $self, $string ) = @_;
12              
13 273         967 $self->SUPER::validate( $string );
14              
15 269         591 eval { "" =~ /$string/ };
  269         1996  
16              
17 269 100       676 if ( $@ ) {
18 2         4 my $type = ref( $self );
19 2         9 $type =~ s/.*:://;
20              
21 2         9 require Enbld::Exception;
22 2         12 croak( Enbld::Exception->new(
23             "Attribute '$type' is NOT valid regular expression string",
24             $string
25             ) );
26             }
27              
28 267         733 return $string;
29             }
30              
31             1;