package DX::Update::SetValue;

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

with 'DX::Role::Update';

has new_value => (is => 'ro', required => 1, isa => Value);

sub apply_to {
  my ($self, $scope) = @_;
  my @path = @{$self->target_path};
  my $new_value = $self->new_value;
  return (
    $self->_with_value_at_path($scope, sub { $new_value }, @path),
    [ VALUE_SET ,=> @path ],
  );
}

1;
