7b40168853a722f55ec9bd7fa1222f744035e961
[scpubgit/DX.git] / lib / DX / Action / SetValue.pm
1 package DX::Action::SetValue;
2
3 use DX::Update::SetValue;
4 use DX::Class;
5
6 has target_path => (is => 'ro', required => 1);
7
8 has new_value => (is => 'ro', required => 1);
9
10 has _update => (is => 'lazy');
11
12 sub dry_run {
13   my ($self, $hyp) = @_;
14   my ($scope, @events) = $self->_update->apply_to($hyp->scope);
15   return (
16     $hyp->but(
17       actions => [ @{$hyp->actions}, $self ],
18       scope => $scope
19     ),
20     @events,
21   );
22 }
23
24 sub _build__update {
25   my ($self) = @_;
26   DX::Update::SetValue->new(
27     target_path => $self->target_path,
28     new_value => $self->new_value,
29   );
30 }
31
32 1;