convert dict predicate to rspace and refactor
[scpubgit/DX.git] / lib / DX / Predicate / Dict.pm
CommitLineData
9fd6087b 1package DX::Predicate::Dict;
efad53c4 2
feceff29 3use DX::Utils qw(rspace res dict TYPE_OF);
efad53c4 4use DX::Class;
5
6with 'DX::Role::Predicate';
7
feceff29 8sub _resolution_space_for {
9fd6087b 9 my ($self, $arg, $proto) = @_;
feceff29 10
11 die "dict called with non-dict"
12 if $arg->is_set and not $arg->isa('DX::Value::Dict');
13
14 die "dict called with non-dict prototype"
15 if $proto and not $proto->isa('DX::Value::Dict');
16
17 my $deps = [ [ TYPE_OF ,=> $arg ] ];
18
19 my $actions =
20 $arg->is_set ? [] : [ $arg->action_for_set_value($proto||dict()) ];
21
22 return rspace(
23 geometry_depends_on => $deps,
24 members => [ res(
25 actions => $actions,
26 veracity_depends_on => $deps
27 ) ],
efad53c4 28 );
29}
30
311;