package DX::Predicate::Eq;

use DX::Utils qw(step CONTENTS_OF);
use DX::Class;

with 'DX::Role::Predicate';

sub _possible_resolution_list {
  my ($self, $left, $right) = @_;
  if ($left->equals($right)) {
    return step(
      actions => [],
      depends_on => [
        [ undef ,=> [ CONTENTS_OF ,=> $left ], [ CONTENTS_OF ,=> $right ] ]
      ],
    );
  }
  return (
    do {
      if ($left->is_set and my $set = $right->action_for_set_value($left)) {
        step(
          actions => [ $set ],
          depends_on => [
            [ $right =>
              [ CONTENTS_OF ,=> $left ], [ CONTENTS_OF ,=> $right ]
            ]
          ]
        )
      } else {
        ()
      }
    },
    do {
      if ($right->is_set and my $set = $left->action_for_set_value($right)) {
        step(
          actions => [ $set ],
          depends_on => [
            [ $left =>
              [ CONTENTS_OF ,=> $left ], [ CONTENTS_OF ,=> $right ]
            ]
          ]
        )
      } else {
        ()
      }
    },
  );
}

1;
