From: Matt S Trout Date: Tue, 7 Feb 2017 17:52:20 +0000 (+0000) Subject: lift _make_equal from predicate role to Eq.pm X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=255e1884e387c0971e83542924c91593b05a0739;p=scpubgit%2FDX.git lift _make_equal from predicate role to Eq.pm --- diff --git a/lib/DX/Predicate/Eq.pm b/lib/DX/Predicate/Eq.pm index f6d6082..60bcd42 100644 --- a/lib/DX/Predicate/Eq.pm +++ b/lib/DX/Predicate/Eq.pm @@ -1,11 +1,50 @@ package DX::Predicate::Eq; +use DX::Utils qw(step CONTENTS_OF); use DX::Class; with 'DX::Role::Predicate'; sub _possible_resolution_list { - shift->_make_equal(@_) + 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; diff --git a/lib/DX/Role/Predicate.pm b/lib/DX/Role/Predicate.pm index 832150b..28cb8a1 100644 --- a/lib/DX/Role/Predicate.pm +++ b/lib/DX/Role/Predicate.pm @@ -16,48 +16,6 @@ sub resolution_step_for { return $targ; } -sub _make_equal { - 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 { - () - } - }, - ); -} - sub selection_depends_on { my ($self, @args) = @_; \@args;