Commit | Line | Data |
9d759b64 |
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 | |
0498469a |
11 | sub but_with_dependencies_on { |
12 | my ($self, @deps) = @_; |
13 | $self->but(depends_on => [ @{$self->depends_on}, @deps ]); |
14 | } |
15 | |
9d759b64 |
16 | sub but_with_alternative_step { |
17 | my ($self, $step) = @_; |
18 | bless { %$self, alternative_step => $step }, ref($self); |
19 | } |
20 | |
21 | sub apply_to { |
22 | my ($self, $old_hyp) = @_; |
23 | return ($self->_apply_to_hyp($old_hyp), $self->alternative_step); |
24 | } |
25 | |
26 | sub _apply_to_hyp { |
27 | my ($self, $old_hyp) = @_; |
28 | return undef unless my $hyp = $old_hyp->with_actions(@{$self->actions}); |
29 | return $hyp->resolve_head_dependent_on($self->depends_on); |
30 | } |
31 | |
32 | 1; |