add value_path method and give action builders a path
[scpubgit/DX.git] / lib / DX / ActionBuilder / UnsetValue.pm
CommitLineData
efad53c4 1package DX::ActionBuilder::UnsetValue;
2
3use DX::Action::SetValue;
4use DX::ActionBuilder::Normal;
1e90aa03 5use DX::Action::BindValue;
6use DX::ActionBuilder::BoundValue;
efad53c4 7use DX::Class;
8
9with 'DX::Role::ActionBuilder';
10
11has target_path => (is => 'ro', required => 1);
12
13sub action_for_set_value {
14 my ($self, $value) = @_;
1e90aa03 15 if (my $p = $value->identity_path) {
16 my $ab = DX::ActionBuilder::BoundValue->new(
17 target_path => $self->target_path,
18 rebind_path => $self->target_path,
19 bound_to_path => $p,
20 inner_action_builder => $value->action_builder,
21 );
22 return DX::Action::BindValue->new(
23 target_path => $self->target_path,
3a630a54 24 new_value => $ab->apply_to_value($value, $value),
1e90aa03 25 )
efad53c4 26 }
3a630a54 27 DX::ActionBuilder::Normal->new(
efad53c4 28 target_path => $self->target_path,
3a630a54 29 )->action_for_set_value($value);
efad53c4 30}
31
321;