Created
September 24, 2012 14:19
-
-
Save melo/3776179 to your computer and use it in GitHub Desktop.
Open-ended role exclusion
This file contains hidden or 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
package C1; | |
use Moose; | |
with 'R1'; ## this works | |
with 'R2'; ## this also works | |
with 'R1', 'R2'; ## this will fail | |
1; |
This file contains hidden or 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
package H; | |
## This is a placeholder role: any class can only have one role that implements this H role | |
## you could think of this as an abstract role (yuck) | |
use Moose::Role; | |
1; |
This file contains hidden or 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
package R1; | |
## R1 is a role, with one of the possible implementations for H. | |
use Moose::Role; | |
with 'H'; | |
excludes 'H'; | |
1; |
This file contains hidden or 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
package R2; | |
## R2 is a role, with another of the possible implementations for H. | |
use Moose::Role; | |
with 'H'; | |
excludes 'H'; | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment