X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDX%2FOp%2FApplyConstraint.pm;h=093ede6a00f85c0c3d8aa8fa41f24bc50e1ac36d;hb=385fa95470eee7f352b6a3ef3a082f8fbbc2d174;hp=1dfee281def4e677ea9a6ce69f92b192b83916ac;hpb=606537d11c86a39c770d5fc681f402b5ff2c741c;p=scpubgit%2FDKit.git diff --git a/lib/DX/Op/ApplyConstraint.pm b/lib/DX/Op/ApplyConstraint.pm index 1dfee28..093ede6 100644 --- a/lib/DX/Op/ApplyConstraint.pm +++ b/lib/DX/Op/ApplyConstraint.pm @@ -7,9 +7,16 @@ with 'DX::Role::Op'; has vars => (is => 'ro', required => 1); has constraint => (is => 'ro', required => 1); +has _arg_map => (is => 'lazy', builder => sub { + my ($self) = @_; + my $name = 'arg0'; + +{ map +($name++, $_), @{$self->vars} }; +}); + sub run { my ($self, $state) = @_; - my @vars = map $state->scope_var($_)->bound_value, @{$self->vars}; + ($state, my %args) = $self->_expand_args($state, %{$self->_arg_map}); + my @vars = map $_->bound_value, @args{sort keys %args}; if ($self->constraint->(@vars)) { return $state->then($self->next); }