From: Matt S Trout Date: Sat, 12 Mar 2016 02:39:56 +0000 (+0000) Subject: make member_at with unbound key actually work X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4aeeab1e335ed10e9c454f6408537ea0ea85fb2f;p=scpubgit%2FDX.git make member_at with unbound key actually work --- diff --git a/lib/DX/ActionBuilder/Null.pm b/lib/DX/ActionBuilder/Null.pm index c39cb46..3bcea18 100644 --- a/lib/DX/ActionBuilder/Null.pm +++ b/lib/DX/ActionBuilder/Null.pm @@ -4,6 +4,8 @@ use DX::Class; with 'DX::Role::ActionBuilder'; +sub target_path { [ 'N/A' ] } + sub can_set_value { 0 } sub action_for_set_value { undef } diff --git a/lib/DX/Predicate/MemberAt.pm b/lib/DX/Predicate/MemberAt.pm index 3874cb8..95a3f64 100644 --- a/lib/DX/Predicate/MemberAt.pm +++ b/lib/DX/Predicate/MemberAt.pm @@ -1,6 +1,6 @@ package DX::Predicate::MemberAt; -use DX::Utils qw(step INDICES_OF EXISTENCE_OF CONTENTS_OF); +use DX::Utils qw(step INDICES_OF EXISTENCE_OF CONTENTS_OF string); use DX::Class; with 'DX::Role::Predicate'; @@ -45,11 +45,11 @@ sub _possible_resolution_list { ), ($key->can_set_value ? map { - my $set_key = $key->action_for_set_value($_); + my $set_key = $key->action_for_set_value(string(my $kstr = $_)); map $_->but_first($set_key) ->but_with_dependencies_on( [ undef ,=> - [ EXISTENCE_OF ,=> $coll, $key->string_value ] + [ EXISTENCE_OF ,=> $coll, $kstr ] ] ), $self->_make_equal($coll->get_member_at($_), $value); diff --git a/lib/DX/Step/Normal.pm b/lib/DX/Step/Normal.pm index e2c705e..8034c8c 100644 --- a/lib/DX/Step/Normal.pm +++ b/lib/DX/Step/Normal.pm @@ -12,6 +12,11 @@ has depends_on => (is => 'ro', isa => DependencyGroupList, required => 1); has alternative_step => (is => 'ro', isa => Step); +sub but_first { + my ($self, @actions) = @_; + $self->but(actions => [ @actions, @{$self->actions} ]); +} + sub but_with_dependencies_on { my ($self, @deps) = @_; $self->but(depends_on => [ @{$self->depends_on}, @deps ]);