Guys,

Thanks for the responses.

On Sun, May 9, 2010 at 7:29 AM, Jesse Luehrs <d...@tozt.net> wrote:
> So... is there a reason that using 'with' in the class definition isn't
> sufficient? (The subject line mentions runtime application, but your
> code sample below is a Moose::Exporter package, which seems to be
> counter to that idea.)
>

I suppose I should have provided some more detail in the initial post.
(I was up all night and a little drunk though. :) )

Whenever somebody uses my Exporter class to import my sugar functions,
I want their class to use my custom metaclass (I have this part
working) and _also_ use a particular role automatically. I could have
them simply use 'with', but the idea is that _every_ class that uses
this Exporter module should also use this particular role, so I'm just
trying to save a little typing.

> The thing you're looking for is
> Moose::Util::apply_all_roles, like so:

Thanks! I think this is the crucial bit I was missing. I'll give this a shot.

> On another note, it's typically preferable to create metaclass traits
> rather than writing an actual metaclass yourself - this makes it work
> more nicely with other extensions (such as various MooseX modules). It
> probably won't harm anything if this is an app-specific metaclass
> extension that you're only writing one variation of, but it also
> wouldn't harm anything for it to be a role, and getting used to the good
> practice would probably help in the future. In that case, the exporter
> would look something like:

I'll take a look into metaclass traits as well - I still don't really
understand what they do, but I haven't tried them yet. I think if I
can get the runtime role application working, it will be sufficient
for my purposes.


Thanks,

Mike

Reply via email to