Commit | Line | Data |
9d759b64 |
1 | package DX::ActionBuilder::Null; |
2 | |
3 | use DX::Class; |
4 | |
5 | with 'DX::Role::ActionBuilder'; |
6 | |
345270ac |
7 | has target_path => (is => 'ro'); |
4aeeab1e |
8 | |
e1bcd735 |
9 | around target_path => sub { |
10 | my ($orig, $self) = (shift, shift); |
11 | return undef unless ref($self); |
12 | return $self->$orig(@_); |
13 | }; |
14 | |
9d759b64 |
15 | sub can_set_value { 0 } |
16 | |
17 | sub action_for_set_value { undef } |
18 | |
19 | sub action_for_add_member { undef } |
20 | |
21 | sub action_for_set_member { undef } |
22 | |
23 | sub action_for_remove_member { undef } |
24 | |
345270ac |
25 | sub specialize_for_member { |
26 | my ($self, $at) = @_; |
27 | return $self unless ref($self); |
28 | return $self unless my $path = $self->target_path; |
29 | return $self->but( |
30 | target_path => [ @{$self->target_path}, $at ] |
31 | ); |
32 | } |
33 | |
34 | sub apply_to_value { |
35 | my ($self, $value) = @_; |
7a5595d3 |
36 | my $new_value = $value->but_set_action_builder($self); |
345270ac |
37 | return $new_value unless $new_value->isa('DX::Value::Dict'); |
38 | my %m = %{$new_value->members}; |
39 | return $new_value->but( |
40 | members => { |
41 | map +($_ => $self->specialize_for_member($_)->apply_to_value($m{$_})), |
42 | keys %m, |
43 | }, |
44 | ); |
45 | } |
9d759b64 |
46 | |
47 | 1; |