File Coverage

blib/lib/Build/Hopen/G/Node.pm
Criterion Covered Total %
statement 17 19 89.4
branch 5 8 62.5
condition 0 2 0.0
subroutine 5 5 100.0
pod 1 1 100.0
total 28 35 80.0


line stmt bran cond sub pod time code
1             # Build::Hopen::G::Node - base class for hopen nodes
2             package Build::Hopen::G::Node;
3 6     6   2935 use Build::Hopen;
  6         11  
  6         250  
4 6     6   30 use Build::Hopen::Base;
  6         12  
  6         27  
5              
6             our $VERSION = '0.000006'; # TRIAL
7              
8             sub outputs;
9              
10 6     6   1199 use parent 'Build::Hopen::G::Runnable';
  6         11  
  6         33  
11 6     6   261 use Class::Tiny qw(outputs);
  6         10  
  6         21  
12              
13             =head1 NAME
14              
15             Build::Hopen::G::Node - The base class for all hopen nodes
16              
17             =head1 VARIABLES
18              
19             =head2 outputs
20              
21             Hashref of the outputs from the last time this node was run. Default C<{}>.
22              
23             =cut
24              
25             =head1 FUNCTIONS
26              
27             =head2 outputs
28              
29             Custom accessor for outputs, which enforces the invariant that outputs must
30             be hashrefs.
31              
32             =cut
33              
34             sub outputs {
35 6 50   6 1 11 my $self = shift or croak 'Need an instance';
36 6 100       16 if (@_) { # Setter
    50          
37 3 50 0     9 croak "Cannot set `outputs` of @{[$self->name]} to non-hashref " .
  0         0  
38             ($_[0] // '(undef)')
39             unless ref $_[0] eq 'HASH';
40 3         9 return $self->{outputs} = shift;
41             } elsif ( exists $self->{outputs} ) { # Getter
42 3         13 return $self->{outputs};
43             } else { # Default
44 0           return +{};
45             }
46             } #outputs()
47              
48             #DEBUG: sub BUILD { use Data::Dumper; say __PACKAGE__,Dumper(\@_); }
49             1;
50             __END__