File Coverage

blib/lib/BioX/Workflow/Command/run/Utils/Debug.pm
Criterion Covered Total %
statement 6 6 100.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 8 8 100.0


line stmt bran cond sub pod time code
1             package BioX::Workflow::Command::run::Utils::Debug;
2              
3 1     1   557 use Storable qw(dclone);
  1         7  
  1         61  
4              
5 1     1   9 use Moose::Role;
  1         4  
  1         9  
6              
7             =head1 BioX::Workflow::Command::run::utils::Debug
8              
9             Options for debugging. Stick your whole environment in memory, and figure out what went wrong.
10              
11             =head2 Variables
12              
13             =head3 save_object_env
14              
15             Save object env. This will save all the variables. Useful for debugging, but gets unweildly for larger workflows.
16              
17             =cut
18              
19             option 'save_object_env' => (
20             is => 'rw',
21             isa => 'Bool',
22             default => 0,
23             predicate => 'has_save_object_env',
24             clearer => 'clear_save_object_env',
25             );
26              
27             =head2 _classes
28              
29             Saves a snapshot of the entire namespace for the initial environment, and each rule.
30              
31             =cut
32              
33             has '_classes' => (
34             is => 'rw',
35             isa => 'HashRef',
36             default => sub { return {} },
37             required => 0,
38             predicate => 'has_classes',
39             clearer => 'clear_classes',
40             );
41              
42             =head2 save_env
43              
44             At each rule save the env for debugging purposes.
45              
46             =cut
47              
48             sub save_env {
49             my $self = shift;
50              
51             return unless $self->save_object_env;
52              
53             $DB::single = 2;
54             $self->_classes->{ $self->key } = dclone($self);
55             return;
56             $DB::single = 2;
57             }
58              
59             1;