member_at starting to work
[scpubgit/DX.git] / lib / DX / ActionBuilder / Normal.pm
1 package DX::ActionBuilder::Normal;
2
3 use DX::Action::SetValue;
4 use DX::Action::AddValue;
5 use DX::Class;
6
7 with 'DX::Role::ActionBuilder';
8
9 has target_path => (is => 'ro', required => 1);
10
11 sub action_for_set_value {
12   my ($self, $value) = @_;
13   DX::Action::SetValue->new(
14     target_path => $self->target_path,
15     new_value => $value->but_set_action_builder($self)
16   );
17 }
18
19 sub action_for_add_member {
20   my ($self, $at, $value) = @_;
21   my @add_path = (@{$self->target_path}, ref($at) ? $at->string_value : $at);
22   DX::Action::AddValue->new(
23     target_path => \@add_path,
24     new_value => $value->but_set_action_builder(
25                    $self->but(target_path => \@add_path)
26                  )
27   );
28 }
29
30 sub action_for_remove_member { die 'WHUT' }
31
32 1;