1 package DX::Op::ProposeAction;
3 use DX::ObservationRequired;
8 has vars => (is => 'ro', required => 1);
9 has builder => (is => 'ro', required => 1);
11 has _arg_map => (is => 'lazy', builder => sub {
14 +{ map +($name++, $_), @{$self->vars} };
18 my ($self, $state) = @_;
19 ($state, my %args) = $self->_expand_args($state, %{$self->_arg_map});
20 my @vars = @args{sort keys %args};
21 my $action = $self->builder->(@vars);
22 my ($id, $value) = $action->expected_effect;
23 my $var = $state->by_id->{$id}->with_value($value)->with_action($action);
24 $state->but(by_id => { %{$state->by_id}, $id => $var })