package DX::Predicate::Dict;

use DX::Utils qw(rspace res dict TYPE_OF expand_deps);
use DX::Class;

with 'DX::Role::Predicate';

sub _resolution_space_for {
  my ($self, $arg, $proto) = @_;

  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 = expand_deps([ [ TYPE_OF ,=> $arg ] ]);

  my $actions =
    $arg->is_set ? [] : [ $arg->action_for_set_value($proto||dict()) ];

  return rspace(
    geometry_depends_on => $deps,
    aperture => $arg->aperture_for_set_value,
    members => [ res(
      actions => $actions,
      veracity_depends_on => $deps
    ) ],
  );
}

1;
