make member_at with unbound key actually work
[scpubgit/DX.git] / lib / DX / Step / Normal.pm
CommitLineData
9d759b64 1package DX::Step::Normal;
2
3e465d5d 3use Types::Standard qw(ArrayRef);
4016201b 4use DX::Utils qw(deparse);
9d759b64 5use DX::Class;
6
3e465d5d 7with 'DX::Role::Step';
9d759b64 8
3e465d5d 9has actions => (is => 'ro', isa => ArrayRef[Action], required => 1);
9d759b64 10
3e465d5d 11has depends_on => (is => 'ro', isa => DependencyGroupList, required => 1);
12
13has alternative_step => (is => 'ro', isa => Step);
9d759b64 14
4aeeab1e 15sub but_first {
16 my ($self, @actions) = @_;
17 $self->but(actions => [ @actions, @{$self->actions} ]);
18}
19
0498469a 20sub but_with_dependencies_on {
21 my ($self, @deps) = @_;
22 $self->but(depends_on => [ @{$self->depends_on}, @deps ]);
23}
24
9d759b64 25sub but_with_alternative_step {
26 my ($self, $step) = @_;
27 bless { %$self, alternative_step => $step }, ref($self);
28}
29
30sub apply_to {
31 my ($self, $old_hyp) = @_;
32 return ($self->_apply_to_hyp($old_hyp), $self->alternative_step);
33}
34
35sub _apply_to_hyp {
36 my ($self, $old_hyp) = @_;
37 return undef unless my $hyp = $old_hyp->with_actions(@{$self->actions});
38 return $hyp->resolve_head_dependent_on($self->depends_on);
39}
40
411;