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]]]
20 has aperture => (is => 'lazy', builder => sub {
23 # [ $thing, 'set_value' ] -> $thing->aperture_for_set_value
24 map @{$_->[0]->${\'aperture_for_'.$_[1]}()},
25 @{$self->action_prototypes}
31 return undef unless my ($first) = @{$self->implementation_candidates};
32 my @ap = @{$self->action_prototypes};
34 return DX::Resolution->new(
37 my ($inv, $type, @args) = @{$ap[$_]};
38 $inv->${\"action_for_${type}"}(@args, @{$cand[$_]});
41 veracity_depends_on => $self->veracity_depends_on_builder->(@cand),
47 my ($first, @rest) = @{$self->implementation_candidates};
48 return () unless @rest;
49 return $self->but(implementation_candidates => \@rest);
55 'resolution_strategy',
57 [ action_prototypes => [ block => [
59 my ($inv, $type, @args) = @$_;
62 [ value_path => $inv->value_path ],
65 } @{$self->action_prototypes}
67 [ implementation_candidates => [ list => [
70 map +($_->value_path ? [ value_path => $_->value_path ] : $_), @$_
72 ] ], @{$self->implementation_candidates}