Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add Junction.ACCEPTS.
  • Loading branch information
pmichaud committed Jul 7, 2011
1 parent 15ec618 commit b4d5e56
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/core/Junction.pm
Expand Up @@ -19,6 +19,25 @@ my class Junction is Mu {
$count == 1;
}

multi method Str(Junction:D:) {
self.new($!storage.map({$_.Str}), :type($!type))
}

multi method ACCEPTS(Junction:D: Mu \$topic) {
($!storage.map({return True if $_.ACCEPTS($topic)}).gimme(*); return False)
if $!type eq 'any';
($!storage.map({return False unless $_.ACCEPTS($topic)}).gimme(*); return True)
if $!type eq 'all';
($!storage.map({return False if $_.ACCEPTS($topic)}).gimme(*); return True)
if $!type eq 'none';
# 'one' junction
my $count = 0;
$!storage.map({ $count++ if $_.ACCEPTS($topic); return False if $count > 1 }).gimme(*);
$count == 1;
}



submethod BUILD(:$!storage, :$!type) { }

multi method perl(Junction:D:) {
Expand Down

0 comments on commit b4d5e56

Please sign in to comment.