pervasive type constraints
[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;
6aa36401 7use DX::Utils qw(VALUE_SET);
efad53c4 8use DX::Class;
9
10with 'DX::Role::ActionBuilder';
11
2548ce61 12has target_path => (is => 'ro', required => 1, isa => ValuePath);
efad53c4 13
6aa36401 14sub aperture_for_set_value {
15 [ [ VALUE_SET ,=> @{$_[0]->target_path} ] ]
16}
17
efad53c4 18sub 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
371;