pervasive type constraints
[scpubgit/DX.git] / lib / DX / Role / Update.pm
1 package DX::Role::Update;
2
3 use DX::Role;
4
5 has target_path => (is => 'ro', required => 1, isa => ValuePath);
6
7 sub _with_value_at_path {
8   my ($self, $scope, $final_value, @path) = @_;
9   return $final_value->($scope) unless @path;
10   my ($first, @rest) = @path;
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;