1 package DX::Role::BoundValueAction;
5 with 'DX::Role::Action';
7 has target_path => (is => 'ro', required => 1);
9 has bound_to_path => (is => 'ro', required => 1);
11 has rebind_path => (is => 'ro', required => 1);
13 has new_value => (is => 'ro', required => 1);
15 has inner_action => (is => 'ro', required => 1);
17 requires 'update_class';
22 [ symbol => (split('::',ref($self)))[-1] ],
23 [ value_path => $self->target_path ],
29 my ($self, $hyp) = @_;
30 my ($outer_hyp, @inner_events) = $self->inner_action->dry_run(
32 action_applications => [ @{$hyp->action_applications}, $self ],
35 my $new_bound_to = do {
36 my $targ = $outer_hyp->scope;
37 $targ = $targ->get_member_at($_) for @{$self->bound_to_path};
40 my $new_ab = DX::ActionBuilder::BoundValue->new(
41 target_path => $self->target_path,
42 rebind_path => $self->rebind_path,
43 bound_to_path => $self->bound_to_path,
44 inner_action_builder => $new_bound_to->action_builder
46 my $value_with_ab = $new_ab->apply_to_value($self->new_value, $new_bound_to);
47 my ($scope, @events) = $outer_hyp->scope->apply_updates(
48 $self->update_class->new(
49 target_path => $self->target_path,
50 new_value => $value_with_ab,
55 $targ = $targ->get_member_at($_) for @{$self->rebind_path};
58 my @actions = @{$outer_hyp->actions};
59 foreach my $idx (0.. $#actions) {
60 my $act = $actions[$idx];
62 $act->isa('DX::Action::BindValue')
63 and join("\0", @{$act->target_path})
64 eq join("\0", @{$self->rebind_path})
66 my $bind = splice @actions, $idx, 1;
67 push @actions, $bind->but(new_value => $new_bound);
72 $outer_hyp->but(scope => $scope, actions => \@actions),
73 @inner_events, @events