package DX::Update::RemoveValue;

use DX::Utils qw(VALUE_EXISTS);
use DX::Class;

with 'DX::Role::Update';

sub apply_to {
  my ($self, $scope) = @_;
  my @path = my @whole_path = @{$self->target_path};
  my $target = pop @path;
  return (
    $self->_with_value_at_path(
      $scope, sub { $_[0]->without_member_at($target) }, @path
    ),
    [ VALUE_EXISTS ,=> @whole_path ],
  );
}

1;
