rewrite deparse system
[scpubgit/DX.git] / lib / DX / Role / SimpleAction.pm
index dd76714..62bf837 100644 (file)
@@ -2,17 +2,31 @@ package DX::Role::SimpleAction;
 
 use DX::Role;
 
-has updates => (is => 'lazy');
+with 'DX::Role::Action';
 
-requires '_build_updates';
+has target_path => (is => 'ro', required => 1);
 
-sub dry_run_against {
+has _updates => (is => 'lazy');
+
+requires '_build__updates';
+
+sub for_deparse {
+  my ($self) = @_;
+  [ statement => [
+    [ symbol => (split('::',ref($self)))[-1] ],
+    [ value_path => $self->target_path ],
+    $self->new_value,
+  ] ];
+}
+
+sub dry_run {
   my ($self, $hyp) = @_;
-  my ($scope, @events) = $hyp->scope->apply_updates($self->updates);
+  my ($scope, @events) = $hyp->scope->apply_updates($self->_updates);
   return (
     $hyp->but(
       scope => $scope,
       actions => [ @{$hyp->actions}, $self ],
+      action_applications => [ @{$hyp->action_applications}, $self ],
     ),
     @events
   );