lift _make_equal from predicate role to Eq.pm
[scpubgit/DX.git] / lib / DX / Role / Predicate.pm
index b1c8181..28cb8a1 100644 (file)
@@ -1,58 +1,21 @@
 package DX::Role::Predicate;
 
 use List::Util qw(reduce);
-use DX::Utils qw(step);
+use DX::Utils qw(step CONTENTS_OF);
 use DX::Role;
 
 sub resolution_step_for {
-  my ($self, @args) = @_;
+  my ($self, $prop, @args) = @_;
   my ($last, @rest) = reverse $self->_possible_resolution_list(@args);
   return undef unless $last;
-  my $targ = $last;
-  $targ = $_->but_with_alternative_step($targ) for @rest;
+  my $targ = $last->but(resolves => $prop);
+  $targ = $_->but(
+    alternative_step => $targ,
+    resolves => $prop
+  ) for @rest;
   return $targ;
 }
 
-sub _make_equal {
-  my ($self, $left, $right) = @_;
-  if ($left->equals($right)) {
-    return step(
-      actions => [],
-      depends_on => [ [ undef ,=> [ $left, $right ] ] ],
-    );
-  }
-  return (
-    do {
-      if ($left->is_set and my $set = $right->action_for_set_value($left)) {
-        step(
-          actions => [ $set ],
-          depends_on => [
-            [ $right =>
-              [ $left ], [ $right ]
-            ]
-          ]
-        )
-      } else {
-        ()
-      }
-    },
-    do {
-      if ($right->is_set and my $set = $left->action_for_set_value($right)) {
-        step(
-          actions => [ $set ],
-          depends_on => [
-            [ $left =>
-              [ $left ], [ $right ]
-            ]
-          ]
-        )
-      } else {
-        ()
-      }
-    },
-  );
-}
-
 sub selection_depends_on {
   my ($self, @args) = @_;
   \@args;