c7cfbeb2de11327f897702d7f694a9f0b4ed5ba4
[scpubgit/DX.git] / lib / DX / Step / Normal.pm
1 package DX::Step::Normal;
2
3 use DX::Class;
4
5 has actions => (is => 'ro', required => 1);
6
7 has depends_on => (is => 'ro', required => 1);
8
9 has alternative_step => (is => 'ro');
10
11 sub but_with_alternative_step {
12   my ($self, $step) = @_;
13   bless { %$self, alternative_step => $step }, ref($self);
14 }
15
16 sub apply_to {
17   my ($self, $old_hyp) = @_;
18   return ($self->_apply_to_hyp($old_hyp), $self->alternative_step);
19 }
20
21 sub _apply_to_hyp {
22   my ($self, $old_hyp) = @_;
23   return undef unless my $hyp = $old_hyp->with_actions(@{$self->actions});
24   return $hyp->resolve_head_dependent_on($self->depends_on);
25 }
26
27 1;