pervasive type constraints
[scpubgit/DX.git] / lib / DX / Update / AddValue.pm
CommitLineData
9d759b64 1package DX::Update::AddValue;
2
efad53c4 3use DX::Utils qw(VALUE_EXISTS);
9d759b64 4use DX::Class;
5
6with 'DX::Role::Update';
7
2548ce61 8has new_value => (is => 'ro', required => 1, isa => Value);
9d759b64 9
10sub apply_to {
0498469a 11 my ($self, $scope) = @_;
efad53c4 12 my @path = my @whole_path = @{$self->target_path};
9d759b64 13 my $target = pop @path;
14 my $new_value = $self->new_value;
15 return (
16 $self->_with_value_at_path(
17 $scope, sub { $_[0]->with_member_at($target, $new_value) }, @path
18 ),
efad53c4 19 [ VALUE_EXISTS ,=> @whole_path ],
9d759b64 20 );
21}
22
231;