rewrite deparse system
[scpubgit/DX.git] / lib / DX / Role / SimpleAction.pm
CommitLineData
9d759b64 1package DX::Role::SimpleAction;
2
3use DX::Role;
4
3e465d5d 5with 'DX::Role::Action';
6
0498469a 7has target_path => (is => 'ro', required => 1);
9d759b64 8
0498469a 9has _updates => (is => 'lazy');
9d759b64 10
0498469a 11requires '_build__updates';
12
c25fbf05 13sub for_deparse {
14 my ($self) = @_;
15 [ statement => [
16 [ symbol => (split('::',ref($self)))[-1] ],
17 [ value_path => $self->target_path ],
18 $self->new_value,
19 ] ];
20}
21
0498469a 22sub dry_run {
9d759b64 23 my ($self, $hyp) = @_;
0498469a 24 my ($scope, @events) = $hyp->scope->apply_updates($self->_updates);
9d759b64 25 return (
26 $hyp->but(
27 scope => $scope,
28 actions => [ @{$hyp->actions}, $self ],
e442aff8 29 action_applications => [ @{$hyp->action_applications}, $self ],
9d759b64 30 ),
31 @events
32 );
33}
34
35sub run { shift->updates }
36
371;