Commit | Line | Data |
9d759b64 |
1 | package DX::Update::AddValue; |
2 | |
efad53c4 |
3 | use DX::Utils qw(VALUE_EXISTS); |
9d759b64 |
4 | use DX::Class; |
5 | |
6 | with 'DX::Role::Update'; |
7 | |
8 | has new_value => (is => 'ro', required => 1); |
9 | |
10 | sub apply_to { |
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 | |
23 | 1; |