tilly has asked for the
wisdom of the Perl Monks concerning the following question:

I have a class that I'm writing that uses Moose::Exporter. I'd like to be able to force the class that uses it to import an associated role. Is there any reasonable way to do this? The docs suggest that there is, but I'm having trouble making it work.

Just to avoid the possibility of an X-Y problem, the reason why I need Moose::Exporter is to have utility functions that have access to meta. But I'd also like to require that certain other methods are defined. Which is easy to do with a role.

Comment on
Installing role with Moose::Exporter
Replies are listed 'Best First'.

I would try asking this question either on the Moose mailing list or #moose@irc.perl.org. I personally don't know the answer but people who hang out in those two places do. And unfortunately for you, I am really the only one of the Moose code team that hangs out here on Perlmonks.

However in a class that uses this, the role is not applied until after the class compiles. So my test code which tried to call a function inside of the module failed to find the role applied. But if I wait and look for methods later, it all works.