make member_at with unbound key actually work
Matt S Trout [Sat, 12 Mar 2016 02:39:56 +0000 (02:39 +0000)]
lib/DX/ActionBuilder/Null.pm
lib/DX/Predicate/MemberAt.pm
lib/DX/Step/Normal.pm

index c39cb46..3bcea18 100644 (file)
@@ -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 }
index 3874cb8..95a3f64 100644 (file)
@@ -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);
index e2c705e..8034c8c 100644 (file)
@@ -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 ]);