From: Matt S Trout Date: Sun, 14 Jan 2018 20:56:53 +0000 (+0000) Subject: convert dict predicate to rspace and refactor X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=feceff29986a5875d6762a3c8b26acdcaf7088f0;p=scpubgit%2FDX.git convert dict predicate to rspace and refactor --- diff --git a/lib/DX/Predicate/Dict.pm b/lib/DX/Predicate/Dict.pm index 3bbe0a6..262d5bc 100644 --- a/lib/DX/Predicate/Dict.pm +++ b/lib/DX/Predicate/Dict.pm @@ -1,27 +1,30 @@ package DX::Predicate::Dict; -use DX::Utils qw(step dict TYPE_OF); +use DX::Utils qw(rspace res dict TYPE_OF); use DX::Class; with 'DX::Role::Predicate'; -sub _possible_resolution_list { +sub _resolution_space_for { my ($self, $arg, $proto) = @_; - if ($arg->is_set) { - die "dict called with non-dict" - unless $arg->isa('DX::Value::Dict'); - return step( - actions => [], - depends_on => [ [ TYPE_OF ,=> $arg ] ] - ); - } - if ($proto and not $proto->isa('DX::Value::Dict')) { - die "dict called with non-dict prototype"; - } - my $set = $arg->action_for_set_value($proto||dict()); - return step( - actions => [ $set ], - depends_on => [ [ TYPE_OF ,=> $arg ] ] + + die "dict called with non-dict" + if $arg->is_set and not $arg->isa('DX::Value::Dict'); + + die "dict called with non-dict prototype" + if $proto and not $proto->isa('DX::Value::Dict'); + + my $deps = [ [ TYPE_OF ,=> $arg ] ]; + + my $actions = + $arg->is_set ? [] : [ $arg->action_for_set_value($proto||dict()) ]; + + return rspace( + geometry_depends_on => $deps, + members => [ res( + actions => $actions, + veracity_depends_on => $deps + ) ], ); }