Created
July 28, 2015 17:00
-
-
Save ChoHag/3645dd1638a73b32430d to your computer and use it in GitHub Desktop.
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
SAD.pm: | |
use SAD::Special; | |
class SAD { | |
has $!nothing; | |
} | |
SAD/Special.pm: | |
role SAD::Special { | |
has Bool $.special_thing = True; | |
method apply_handles($att: Mu $pkg) { | |
my $accessor = $att.name.substr(2); | |
say "Apply to $accessor."; | |
$!special_thing = False if $accessor ~~ 'other-thing'; | |
} | |
} | |
multi trait_mod:<is>(Attribute $a, :$special!) is export { | |
$a does SAD::Special; | |
} | |
SAD/Thing.pm: | |
use SAD; | |
use SAD::Special; | |
class SAD::Thing { | |
has $.thing is special; | |
has $.other-thing is special; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This will re-export the trait mod so you only have to
use SAD
in Thing.pm