excise remaining identity_path code
[scpubgit/DX.git] / lib / DX / ActionBuilder / Null.pm
CommitLineData
9d759b64 1package DX::ActionBuilder::Null;
2
3use DX::Class;
4
5with 'DX::Role::ActionBuilder';
6
345270ac 7has target_path => (is => 'ro');
4aeeab1e 8
e1bcd735 9around target_path => sub {
10 my ($orig, $self) = (shift, shift);
11 return undef unless ref($self);
12 return $self->$orig(@_);
13};
14
9d759b64 15sub can_set_value { 0 }
16
17sub action_for_set_value { undef }
18
19sub action_for_add_member { undef }
20
21sub action_for_set_member { undef }
22
23sub action_for_remove_member { undef }
24
345270ac 25sub 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
34sub 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
471;