Commit | Line | Data |
efad53c4 |
1 | package DX::ActionBuilder::UnsetValue; |
2 | |
3 | use DX::Action::SetValue; |
4 | use DX::ActionBuilder::Normal; |
1e90aa03 |
5 | use DX::Action::BindValue; |
6 | use DX::ActionBuilder::BoundValue; |
efad53c4 |
7 | use DX::Class; |
8 | |
9 | with 'DX::Role::ActionBuilder'; |
10 | |
11 | has target_path => (is => 'ro', required => 1); |
12 | |
13 | sub 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 | |
32 | 1; |