lift some of the rspace handling into the Resolution* classes
[scpubgit/DX.git] / lib / DX / ResolutionStrategy.pm
index ca3f23a..8c5d65f 100644 (file)
@@ -1,5 +1,6 @@
 package DX::ResolutionStrategy;
 
+use DX::Resolution;
 use DX::Class;
 
 has action_prototypes => (is => 'ro', required => 1);
@@ -17,4 +18,27 @@ has aperture => (is => 'lazy', builder => sub {
   ];
 });
 
+sub next_resolution {
+  my ($self) = @_;
+  return undef unless my ($first) = @{$self->implementation_candidates};
+  my @ap = @{$self->action_prototypes};
+  my @cand = @$first;
+  return DX::Resolution->new(
+    actions => [
+      map {
+        my ($inv, $type, @args) = @{$ap[$_]};
+        $inv->${\"action_for_${type}"}(@args, @{$cand[$_]});
+      } 0..$#ap
+    ],
+    veracity_depends_on => $self->veracity_depends_on_builder->(@cand),
+  );
+}
+
+sub remainder {
+  my ($self) = @_;
+  my ($first, @rest) = @{$self->implementation_candidates};
+  return () unless @rest;
+  return $self->but(implementation_candidates => \@rest);
+}
+
 1;