File Coverage

blib/lib/Schedule/LongSteps/Storage.pm
Criterion Covered Total %
statement 10 16 62.5
branch n/a
condition n/a
subroutine 4 7 57.1
pod 4 4 100.0
total 18 27 66.6


line stmt bran cond sub pod time code
1             package Schedule::LongSteps::Storage;
2             $Schedule::LongSteps::Storage::VERSION = '0.023';
3 16     16   7568 use Moose;
  16         40  
  16         90  
4              
5             =head1 NAME
6              
7             Schedule::LongSteps::Storage - An abstract storage class for steps
8              
9             =cut
10              
11 16     16   96942 use Data::UUID;
  16         8665  
  16         3389  
12              
13             has 'uuid' => ( is => 'ro', isa => 'Data::UUID', lazy_build => 1);
14              
15             sub _build_uuid{
16 13     13   41 my ($self) = @_;
17 13         1726 return Data::UUID->new();
18             }
19              
20              
21              
22             =head2 prepare_due_processes
23              
24             Mark the processes that are due to run as 'running' and
25             returns an array of stored processes.
26              
27             Users: Note that this is meant to be used by L<Schedule::LongSteps>, and not intended
28             to be called directly.
29              
30             Implementors: You will have to implement this method should you wish to implement
31             a new process storage backend.
32              
33             =cut
34              
35             sub prepare_due_processes{
36 0     0 1 0 my ($self) = @_;
37 0         0 die "Please implement this in $self";
38             }
39              
40             =head2 create_process
41              
42             Creates and return a new stored process.
43              
44             =cut
45              
46             sub create_process{
47 0     0 1 0 my ($self, $properties) = @_;
48 0         0 die "Please implement this in $self";
49             }
50              
51             =head2 find_process
52              
53             Returns a stored process based on the given ID, or undef if no such thing exists.
54              
55             Usage:
56              
57             my $stored_process = $this->find_process( $pid );
58              
59             =cut
60              
61             sub find_process{
62 0     0 1 0 my ($self, $pid) = @_;
63 0         0 die "Please implement this in $self";
64             }
65              
66              
67             =head2 update_process
68              
69             Updates the given stored process (as returned by 'find_process')
70             with the given properties.
71              
72             Usage:
73              
74             $this->update_process( $process , { run_at => DateTime->now(), .. } );
75              
76             =cut
77              
78             sub update_process{
79 36     36 1 97 my ($self, $process, $properties) = @_;
80 36         132 $process->update( $properties );
81             }
82              
83             __PACKAGE__->meta()->make_immutable();