eliminate support for dead arrayref argspec type
[scpubgit/DKit.git] / lib / DX / Role / Op.pm
CommitLineData
60cda014 1package DX::Role::Op;
2
3use Moo::Role;
4
5has next => (is => 'ro');
6
7requires 'run';
8
b40d5c51 9sub but {
10 my ($self, @but) = @_;
11 $self->new(%$self, @but);
12}
13
385fa954 14sub _expand_args {
15 my ($self, $state, %spec) = @_;
16 my %args;
a5c3a041 17 foreach my $key (keys %spec) {
18 ($state, $args{$key}) = $self->_expand_argspec($state, $spec{$key});
19 }
385fa954 20 return $state->expand_vars(%args);
21}
22
23sub _expand_argspec {
24 my ($self, $state, $spec) = @_;
25 if (!ref($spec)) {
a5c3a041 26 ($state->has_scope_var($spec)
27 ? ($state, $state->scope_var($spec))
28 : (map { $_, $_->scope_var($spec) } $state->assign_vars($spec => {})));
e183503f 29 } elsif (ref($spec) eq 'SCALAR' or ref($spec) eq 'REF') {
a5c3a041 30 return ($state, +{ bound_value => $$spec });
385fa954 31 } else {
32 die "Argspec incomprehensible";
33 }
34}
35
36
60cda014 371;