Commit | Line | Data |
9fd6087b |
1 | package DX::Predicate::Dict; |
efad53c4 |
2 | |
3 | use DX::Utils qw(step dict TYPE_OF); |
4 | use DX::Class; |
5 | |
6 | with 'DX::Role::Predicate'; |
7 | |
8 | sub _possible_resolution_list { |
9fd6087b |
9 | my ($self, $arg, $proto) = @_; |
efad53c4 |
10 | if ($arg->is_set) { |
9fd6087b |
11 | die "dict called with non-dict" |
efad53c4 |
12 | unless $arg->isa('DX::Value::Dict'); |
13 | return step( |
14 | actions => [], |
0498469a |
15 | depends_on => [ [ undef ,=> [ TYPE_OF ,=> $arg ] ] ] |
efad53c4 |
16 | ); |
17 | } |
9fd6087b |
18 | if ($proto and not $proto->isa('DX::Value::Dict')) { |
19 | die "dict called with non-dict prototype"; |
20 | } |
21 | my $set = $arg->action_for_set_value($proto||dict()); |
efad53c4 |
22 | return step( |
23 | actions => [ $set ], |
0498469a |
24 | depends_on => [ [ undef ,=> [ TYPE_OF ,=> $arg ] ] ] |
efad53c4 |
25 | ); |
26 | } |
27 | |
28 | 1; |