aboutsummaryrefslogtreecommitdiff
path: root/lib/WebCoso/Pipeline/Base.pm
blob: 2402b8476da50f0e849ee437fdc278a88523d69b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package WebCoso::Pipeline::Base; 
use strict;
use warnings;
use WebCoso::X;
use WebCoso::Step;
use base 'Class::Data::Inheritable';
 
__PACKAGE__->mk_classdata('_steps');
 
sub set_steps {
    my ($class,@steps)=@_;
 
    my @step_instances=();
 
    while (@steps) {
        my $step_name=shift @steps;
        my $step_init_args=shift @steps;
 
        my $full_step_name="WebCoso::Step::$step_name";
        if (! WebCoso::Step->is_step($full_step_name)) {
            WebCoso::X::NoSuchStep->throw(
                pipeline => $class,
                step => $_,
            );
        }
 
        push @step_instances,$full_step_name->new($step_init_args);
    }
 
    $class->_steps([@step_instances]);
}
 
sub process {
    my ($class$resource,$stage)=@_;
 
    for my $step (@{$class->_steps()}) {
        $step->process($resource,$stage);
    }
 
    return 1;
}
 
1;