move invoke predicate logic into normal step
[scpubgit/DX.git] / lib / DX / Step / Normal.pm
index 9488e74..10c4eb9 100644 (file)
@@ -25,19 +25,29 @@ sub but_with_dependencies_on {
 }
 
 sub apply_to {
-  my ($self, $old_hyp) = @_;
+  my ($self, $ss) = @_;
+  my $old_hyp = $ss->current_hypothesis;
   trace 'step.apply.old_hyp '.$self => $old_hyp;
   trace 'step.apply.actions '.$self => $self->actions;
   my $new_hyp = $self->_apply_to_hyp($old_hyp);
   return (undef, $self->alternative_step) unless $new_hyp;
   trace 'step.apply.new_hyp '.$self => $new_hyp;
-  return ($new_hyp, $self->alternative_step);
+  my $ns = DX::Step::InvokeNextPredicate->new(
+    proposition => $ss->next_proposition($new_hyp)
+  );
+  return (
+    $ss->but(
+      current_hypothesis => $new_hyp,
+      next_step => $ns,
+    ),
+    $self->alternative_step
+  );
 }
 
 sub _apply_to_hyp {
   my ($self, $old_hyp) = @_;
   return undef unless my $hyp = $old_hyp->with_actions(@{$self->actions});
-  return $hyp->resolve_head_dependent_on($self->depends_on);
+  return $hyp->with_resolution($self->resolves, $self->depends_on);
 }
 
 1;