move actions to being held by fact objects
[scpubgit/DKit.git] / lib / DX / Op / ProposeAction.pm
index 2249496..b1aa7f3 100644 (file)
@@ -22,13 +22,9 @@ sub run {
   my $action = $self->builder->(map $state->resolve_value($_), @vars)
                     ->but(dependencies => \@deps);
   my ($fact_type, $value) = $action->expected_effect;
-  my $id = $vars[0]->id;
-  my $var = $state->by_id->{$id}->with_action($action);
-  my $fact_set = $state->facts->{$fact_type}->with_value($value);
-  $state->but(
-            by_id => { %{$state->by_id}, $id => $var },
-            facts => { %{$state->facts}, $fact_type => $fact_set },
-          )
+  my $final_value = $value->but(required_action => $action);
+  my $fact_set = $state->facts->{$fact_type}->with_value($final_value);
+  $state->but(facts => { %{$state->facts}, $fact_type => $fact_set })
         ->then($self->next);
 }