Commit | Line | Data |
9d759b64 |
1 | package DX::Role::Update; |
2 | |
3 | use DX::Role; |
4 | |
5 | has target_path => (is => 'ro', required => 1); |
6 | |
7 | sub _with_value_at_path { |
8 | my ($self, $scope, $final_value, @path) = @_; |
efad53c4 |
9 | return $final_value->($scope) unless @path; |
9d759b64 |
10 | my ($first, @rest) = @path; |
9d759b64 |
11 | my $inner = $scope->get_member_at($first); |
12 | my $value = ( |
13 | @rest |
14 | ? $self->_with_value_at_path($inner, $final_value, @rest) |
15 | : $final_value->($inner) |
16 | ); |
17 | $scope->with_member_at($first, $value); |
18 | } |
19 | |
20 | 1; |