RuleEngine/TypeDecl.pm

filter: Statementstmt 100% 35 / 35 Branchbran 100% 6 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 100% 2 / 2 totaltotal 100% 52 / 52 CC 4 SCAR 5.1
CC
4
Cov
100%
new
3.0
instantiate
2.0
BEGIN
1.0
CRAP 1.7
« RuleEngine/Engine/Defaults.pm ↑ Summary RuleEngine/Engine/Hooks.pm »
1 package VS::RuleEngine::TypeDecl;
2  
3 33 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 33 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 33 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 33 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 229 ▶sub new {
Subroutine new: called CC=3 SCAR=11.0
Pod documented
10 229 my ($pkg, $type, $defaults, @args) = @_;
11 229 ▶ $defaults = [] if !defined $defaults;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $defaults 35 194 229
12 229 ▶ $defaults = [$defaults] if ref $defaults ne 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $defaults ne "ARRAY" 9 220 229
13 229 my $self = bless [$type, $defaults, \@args], $pkg;
14 229 return $self;
15 }
16  
17 184 ▶sub instantiate {
Subroutine instantiate: called CC=2 SCAR=6.9
Pod documented
18 184 my ($self, $engine) = @_;
19 184 my $instance;
20  
21 184 ▶ if (blessed $self->_pkg) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($self->_pkg)) { } 1 183 184
22 1 $instance = $self->_pkg;
23 }
24 else {
25 183 my %defaults = map { %{$engine->get_defaults($_)} } @{$self->_defaults};
26 183 $instance = $self->_pkg->new(%defaults, @{$self->_args});
27 }
28
29 184 return $instance;
30 }
31  
32 394 ▶sub _pkg {
Subroutine _pkg: called CC=1 SCAR=0.0
33 394 my $self = shift;
34 394 return $self->[0];
35 }
36  
37 183 ▶sub _defaults {
Subroutine _defaults: called CC=1 SCAR=0.0
38 183 my $self = shift;
39 183 return $self->[1];
40 }
41  
42 201 ▶sub _args {
Subroutine _args: called CC=1 SCAR=0.0
43 201 my $self = shift;
44 201 return $self->[2];
45 }
46  
47 33 1;
48 __END__
« RuleEngine/Engine/Defaults.pm ↑ Summary RuleEngine/Engine/Hooks.pm »