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; |
6aa36401 |
7 | use DX::Utils qw(VALUE_SET); |
efad53c4 |
8 | use DX::Class; |
9 | |
10 | with 'DX::Role::ActionBuilder'; |
11 | |
2548ce61 |
12 | has target_path => (is => 'ro', required => 1, isa => ValuePath); |
efad53c4 |
13 | |
6aa36401 |
14 | sub aperture_for_set_value { |
15 | [ [ VALUE_SET ,=> @{$_[0]->target_path} ] ] |
16 | } |
17 | |
efad53c4 |
18 | sub action_for_set_value { |
19 | my ($self, $value) = @_; |
e1bcd735 |
20 | if (my $p = $value->value_path) { |
1e90aa03 |
21 | my $ab = DX::ActionBuilder::BoundValue->new( |
22 | target_path => $self->target_path, |
23 | rebind_path => $self->target_path, |
24 | bound_to_path => $p, |
25 | inner_action_builder => $value->action_builder, |
26 | ); |
27 | return DX::Action::BindValue->new( |
28 | target_path => $self->target_path, |
3a630a54 |
29 | new_value => $ab->apply_to_value($value, $value), |
1e90aa03 |
30 | ) |
efad53c4 |
31 | } |
3a630a54 |
32 | DX::ActionBuilder::Normal->new( |
efad53c4 |
33 | target_path => $self->target_path, |
3a630a54 |
34 | )->action_for_set_value($value); |
efad53c4 |
35 | } |
36 | |
37 | 1; |