262d5bc99cdf0a8303f2b4c90e7c342868cb3572
[scpubgit/DX.git] / lib / DX / Predicate / Dict.pm
1 package DX::Predicate::Dict;
2
3 use DX::Utils qw(rspace res dict TYPE_OF);
4 use DX::Class;
5
6 with 'DX::Role::Predicate';
7
8 sub _resolution_space_for {
9   my ($self, $arg, $proto) = @_;
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     ) ],
28   );
29 }
30
31 1;