Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
"on" can have multiple supplies with same effect
  • Loading branch information
lizmat committed Apr 19, 2014
1 parent c27f546 commit 22ca110
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/core/Supply.pm
Expand Up @@ -145,22 +145,29 @@ sub on(&setup) {
my @tappers = &!setup(self);
my $lock = Lock.new;

for @tappers -> $tap {
unless $tap ~~ Pair && $tap.key ~~ Supply {
sub add ($source, $what) {
unless $source ~~ Supply {
X::Supply::On::BadSetup.new.throw;
}
given $tap.value {
given $what {
when EnumMap {
self!add_source($tap.key, $lock, |$tap.value);
self!add_source($source, $lock, |$what);
}
when Callable {
self!add_source($tap.key, $lock, more => $tap.value);
self!add_source($source, $lock, more => $what);
}
default {
X::Supply::On::BadSetup.new.throw;
}
}
}

for @tappers -> $tap {
unless $tap ~~ Pair {
X::Supply::On::BadSetup.new.throw;
}
add( $_, $tap.value ) for $tap.key;
}
$sub
}

Expand Down

0 comments on commit 22ca110

Please sign in to comment.