add exhaustionstep and resumesearch concepts
[scpubgit/DX.git] / lib / DX / Step / ResumeSearch.pm
diff --git a/lib/DX/Step/ResumeSearch.pm b/lib/DX/Step/ResumeSearch.pm
new file mode 100644 (file)
index 0000000..90693cc
--- /dev/null
@@ -0,0 +1,28 @@
+package DX::Step::ResumeSearch;
+
+use DX::Class;
+
+with 'DX::Role::Step';
+
+sub apply_to {
+  my ($self, $ss) = @_;
+  trace resume => [ statement => [ [ symbol => 'resume' ] ] ];
+  foreach my $adj (@{$ss->decisions_taken}) {
+    my ($rspace_was, $ss_was) = @$adj;
+    next unless @{$rspace_was->remaining_resolution_space->members};
+    trace rspace => [ statement => [
+      [ symbol => 'remaining' ],
+      @{$rspace_was->remaining_resolution_space->for_deparse->[1]}
+    ] ];
+    return $ss_was->but(
+      is_solution_state => 0,
+      next_step => $rspace_was->remaining_resolution_space->next_step
+    );
+  }
+  return $ss->but(
+    is_solution_state => 0,
+    next_step => $ss->on_exhaustion_step
+  );
+}
+
+1;