Hopen/G/Node.pm

filter: Statementstmt 100% 25 / 25 Branchbran 100% 8 / 8 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 6 / 6 Podpod 100% 1 / 1 totaltotal 100% 43 / 43 CC 6 SCAR 13.2
CC
6
Cov
100%
outputs
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.7
« Hopen.pm ↑ Summary Hopen/G/Runnable.pm »
1 # Data::Hopen::G::Node - base class for hopen nodes
2 package Data::Hopen::G::Node;
3 12 ▶use Data::Hopen;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 12 ▶use Data::Hopen::Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 12 our $VERSION = '0.000018';
8  
9 sub outputs;
10  
11 12 ▶use parent 'Data::Hopen::G::Runnable';
Subroutine BEGIN: called CC=1 SCAR=0.0
12 12 ▶use Class::Tiny qw(outputs);
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 =head1 NAME
15  
16 Data::Hopen::G::Node - The base class for all hopen nodes
17  
18 =head1 VARIABLES
19  
20 =head2 outputs
21  
22 Hashref of the outputs from the last time this node was run. Default C<{}>.
23  
24 =cut
25  
26 =head1 FUNCTIONS
27  
28 =head2 outputs
29  
30 Custom accessor for outputs, which enforces the invariant that outputs must
31 be hashrefs.
32  
33 =cut
34  
35 sub outputs {
36 190 ▶ my $self = shift;
Subroutine outputs: called CC=6 SCAR=17.9
Pod documented
37 190 ▶ croak 'Need an instance' unless $self;
Branch: 1 branch
BranchTrueFalseTotal
unless $self 1 189 190
38 189 ▶ if (@_) { # Setter
Branch: 2 branches
BranchTrueFalseTotal
if (@_) { } 63 126 189
elsif (exists $self->{'outputs'}) { } 125 1 126
39 63 ▶ croak "Cannot set `outputs` of @{[$self->name]} to non-hashref " .
Branch: 1 branch
BranchTrueFalseTotal
unless ref $_[0] eq "HASH" 2 61 63
Condition100%2/2
$_[0] // "(undef)"
l!l
11
MC/DC100%1/1
$_[0] // "(undef)"
$_[0]
Truth table100%2/2
A
A= $_[0]
Aresult
11
00
40 ($_[0] // '(undef)')
41 unless ref $_[0] eq 'HASH';
42 61 return $self->{outputs} = shift;
43 } elsif ( exists $self->{outputs} ) { # Getter
44 125 return $self->{outputs};
45 } else { # Default
46 1 return +{};
47 }
48 } #outputs()
49  
50 #DEBUG: sub BUILD { use Data::Dumper; say __PACKAGE__,Dumper(\@_); }
51 12 1;
52 __END__
« Hopen.pm ↑ Summary Hopen/G/Runnable.pm »