File Coverage

blib/lib/VS/RuleEngine/Engine/Common.pm
Criterion Covered Total %
statement 25 25 100.0
branch 20 20 100.0
condition n/a
subroutine 5 5 100.0
pod n/a
total 50 50 100.0


line stmt bran cond sub pod time code
1 32     32   168 use strict;
  32         58  
  32         1064  
2 32     32   169 use warnings;
  32         58  
  32         845  
3              
4 32     32   151 use Scalar::Util qw(blessed);
  32         54  
  32         1447  
5              
6 32     32   170 use VS::RuleEngine::Util qw(is_valid_name is_valid_package_name is_existing_package);
  32         67  
  32         11731  
7              
8             sub _check_add_args {
9 259     259   476 my ($self, $type, $has, $name, $obj) = @_;
10            
11 259 100       743 croak "Name is undefined" if !defined $name;
12 255 100       716 croak "Name '${name}' is invalid" if !is_valid_name($name);
13 251 100       715 croak "${type} is undefined" if !defined $obj;
14            
15 248 100       798 croak "${type} '${name}' is already defined" if $has->($self, $name);
16            
17 244 100       822 if (blessed $obj) {
18 14 100       190 croak "${type} is an instance that does not conform to VS::RuleEngine::${type}" if !$obj->isa("VS::RuleEngine::${type}");
19             }
20             else {
21 230 100       621 croak "${type} '${obj}' doesn't look like a valid class name" if !is_valid_package_name($obj);
22 222 100       591 if (!is_existing_package($obj)) {
23 16         1371 eval "require ${obj};";
24 16 100       180 croak $@ if $@;
25             }
26            
27 218 100       1238 croak "${type} '${obj}' does not conform to VS::RuleEngine::${type}" if !UNIVERSAL::isa($obj, "VS::RuleEngine::${type}");
28             }
29            
30 224         597 1;
31             }
32              
33             1;
34             __END__