I have a Role and several classes that mix-in the role. The Role class loads all of the implementing classes so that anything that imports Blah can use them without typing a lot of 'use' lines.
package Blah;
use Moose::Role;
use Blah::A;
use Blah::B;
(etc...)
requires '...';
requires 'foo';
around 'foo' => sub { ... }
A typical Blah subclass:
package Blah::A;
use Moose;
with 'Blah';
sub foo { ... }
__PACKAGE__->meta->make_immutable;
Since every subclass 'foo' method starts with the same bits of code, the role also implements these via a method modifier.
Problem is: Moose doesn't apply the method modifier to any of the Blah::* classes. This happens even if I remove the make_immutable call for the classes. I thought role application was done entirely at runtime, and so even though the Blah::* classes are loaded before Blah, the modifier should still be applied?
I'm looking for a fix, or an alternate way of doing things. At the moment Blah is essentially an abstract base class except for the method modifier, which is why I used roles to begin with - but maybe a class hierarchy would be better? Thanks in advance.