1 package DX::ResolutionStrategy;
4 use Types::Standard qw(CodeRef Tuple slurpy);
7 has action_prototypes => (
8 is => 'ro', required => 1,
9 isa => ArrayRef[Tuple[Value, Str, slurpy ArrayRef[Value]]]
12 has veracity_depends_on_builder => (
13 is => 'ro', required => 1, isa => CodeRef
16 has implementation_candidates => (
17 is => 'ro', required => 1, isa => ArrayRef[ArrayRef[ArrayRef[Value]]]
22 return undef unless my ($first) = @{$self->implementation_candidates};
23 my @ap = @{$self->action_prototypes};
25 return DX::Resolution->new(
28 my ($inv, $type, @args) = @{$ap[$_]};
29 $inv->${\"action_for_${type}"}(@args, @{$cand[$_]});
32 veracity_depends_on => $self->veracity_depends_on_builder->(@cand),
38 my ($first, @rest) = @{$self->implementation_candidates};
39 return () unless @rest;
40 return $self->but(implementation_candidates => \@rest);
46 'resolution_strategy',
48 [ action_prototypes => [ block => [
50 my ($inv, $type, @args) = @$_;
53 [ value_path => $inv->value_path ],
56 } @{$self->action_prototypes}
58 [ implementation_candidates => [ list => [
61 map +($_->value_path ? [ value_path => $_->value_path ] : $_), @$_
63 ] ], @{$self->implementation_candidates}