Commit | Line | Data |
60cda014 |
1 | package DX::Role::Op; |
2 | |
3 | use Moo::Role; |
4 | |
5 | has next => (is => 'ro'); |
6 | |
7 | requires 'run'; |
8 | |
b40d5c51 |
9 | sub but { |
10 | my ($self, @but) = @_; |
11 | $self->new(%$self, @but); |
12 | } |
13 | |
385fa954 |
14 | sub _expand_args { |
15 | my ($self, $state, %spec) = @_; |
16 | my %args; |
17 | @args{keys %spec} = map $self->_expand_argspec($state, $_), values %spec; |
18 | return $state->expand_vars(%args); |
19 | } |
20 | |
21 | sub _expand_argspec { |
22 | my ($self, $state, $spec) = @_; |
23 | if (!ref($spec)) { |
24 | $state->scope_var($spec) |
25 | } elsif (ref($spec) eq 'ARRAY') { |
26 | if ($spec->[0] eq 'value') { |
27 | +{ bound_value => $spec->[1] }; |
28 | } else { |
29 | die "Arrayref in argspec is not value"; |
30 | } |
31 | } else { |
32 | die "Argspec incomprehensible"; |
33 | } |
34 | } |
35 | |
36 | |
60cda014 |
37 | 1; |