wheeeeeeeeee
[scpubgit/DKit.git] / lib / DX / Op / ApplyConstraint.pm
1 package DX::Op::ApplyConstraint;
2
3 use Moo;
4
5 with 'DX::Role::Op';
6
7 has vars => (is => 'ro', required => 1);
8 has constraint => (is => 'ro', required => 1);
9
10 sub run {
11   my ($self, $state) = @_;
12   my @vars = map $state->scope_var($_)->bound_value, @{$self->vars};
13   if ($self->constraint->(@vars)) {
14     return $state->then($self->next);
15   }
16   return $state->backtrack;
17 }
18
19 1;