Skip to content

Instantly share code, notes, and snippets.

@melo
Created September 24, 2012 14:19
Show Gist options
  • Save melo/3776179 to your computer and use it in GitHub Desktop.
Save melo/3776179 to your computer and use it in GitHub Desktop.
Open-ended role exclusion
package C1;
use Moose;
with 'R1'; ## this works
with 'R2'; ## this also works
with 'R1', 'R2'; ## this will fail
1;
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;
package R1;
## R1 is a role, with one of the possible implementations for H.
use Moose::Role;
with 'H';
excludes 'H';
1;
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