File Coverage

blib/lib/Event/ExecFlow/Job/Code.pm
Criterion Covered Total %
statement 22 32 68.7
branch 1 2 50.0
condition n/a
subroutine 7 11 63.6
pod 0 9 0.0
total 30 54 55.5


line stmt bran cond sub pod time code
1             package Event::ExecFlow::Job::Code;
2              
3 2     2   18 use base qw( Event::ExecFlow::Job );
  2         29  
  2         416  
4              
5 2     2   15 use strict;
  2         4  
  2         821  
6              
7 0     0 0 0 sub get_exec_type { "sync" }
8 16     16 0 89 sub get_type { "code" }
9              
10 1     1 0 3 sub get_code { shift->{code} }
11 1     1 0 8 sub set_code { shift->{code} = $_[1] }
12              
13             sub new {
14 1     1 0 18 my $class = shift;
15 1         8 my %par = @_;
16 1         3 my ($code) = $par{'code'};
17              
18 1         9 my $self = $class->SUPER::new(@_);
19              
20 1         13 $self->set_code($code);
21              
22 1         4 return $self;
23             }
24              
25             sub execute {
26 1     1 0 3 my $self = shift;
27            
28 1         9 my $code = $self->get_code;
29            
30 1         4 eval { $code->($self) };
  1         8  
31 1 50       30 $self->set_error_message($@) if $@;
32            
33 1         21 $self->execution_finished;
34            
35 1         12 1;
36             }
37              
38             sub cancel {
39 0     0 0   my $self = shift;
40              
41 0           $self->set_cancelled(1);
42              
43 0           1;
44             }
45              
46             sub pause_job {
47 0     0 0   my $self = shift;
48              
49 0           1;
50             }
51              
52             sub backup_state {
53 0     0 0   my $self = shift;
54            
55 0           my $data_href = $self->SUPER::backup_state();
56            
57 0           delete $data_href->{code};
58            
59 0           return $data_href;
60             }
61              
62             1;
63              
64             __END__