Created
November 16, 2017 11:15
Star
You must be signed in to star a gist
Module-wide multi overriding
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| use v6; | |
| unit module Foo; | |
| our proto sub bar(|) {*} | |
| multi bar( | |
| Hash $config, | |
| *%sig where { is-overridden $config, $?PACKAGE, &?ROUTINE }) { | |
| override($config<overrides>{ me }, :$config, :%sig); | |
| } | |
| # default core version of bar | |
| multi bar() { | |
| return "blah"; | |
| } | |
| # %config looks like this | |
| # %{ | |
| # overrides => %{ 'Foo::bar' => 'MyOtherModule::bar' } | |
| # } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment