Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Implement Hash ~~ Pair smartmatching
  • Loading branch information
Moritz Lenz committed Jul 7, 2009
1 parent 99ad1eb commit 9f63647
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/setting/Pair.pm
Expand Up @@ -3,10 +3,19 @@ class Pair is also {
=begin item ACCEPTS()
Called from smartmatches '$_ ~~ X'.
Delegates on to a method call '.:Xkey(Xval)'.
For C<$_ ~~ Mapping> tests if C<$_{X.key} ~~ X.value>
Else it delegates to a method call '.:Xkey(Xval)'
(TODO: should actually be .Xkey, not .:Xkey).
=end item
method ACCEPTS($topic) {

multi method ACCEPTS(Mapping $topic) {
$topic{$.key} ~~ $.value;
}

multi method ACCEPTS($topic) {
my $meth_name = ':' ~ $.key;
return $topic."$meth_name"($.value);
}
Expand Down

0 comments on commit 9f63647

Please sign in to comment.