in reply to SOLVED [ create_class_with_roles() ]: Moo[se] namespace weirdness with conditionally composed-in Roles

So you're wanting to have the role have the same name but be from different classes?

You want one role to override another?

update: https://metacpan.org/pod/distribution/Moose/lib/Moose/Manual/Roles.pod#METHOD-EXCLUSION-AND-ALIASING

with 'Breakable' => { -alias => { break => 'break_bone' } }, 'Breakdancer' => { -alias => { break => 'break_dance' } };

Now does Moo/Moo::Role or Role::Tiny support alias for with?

  • Comment on Re: Moo[se] namespace weirdness with conditionally composed-in Roles (two roles with the same name, with alias)
  • Download Code

Replies are listed 'Best First'.
Re^2: Moo[se] namespace weirdness with conditionally composed-in Roles (two roles with the same name, with alias)
by 1nickt (Canon) on Mar 21, 2016 at 08:25 UTC

    Thank you for your reply. That's not what I am attempting though: I want to load only one Role, based on a condition.


    The way forward always starts with a minimal test.
Re^2: Moo[se] namespace weirdness with conditionally composed-in Roles (two roles with the same name, with alias)
by Anonymous Monk on Mar 21, 2016 at 07:49 UTC
    Naturally adding  with 'Odd', 'Even'; yields  Due to a method name conflict between roles 'Even and Odd', the method 'bar' must be implemented by 'MyClass' :)

      Right. I'm not trying to load more than one Role with a method of the same name, though. I want to load one or the other and have the parent execute the loaded module's methods when called. Looks like I can get what I want with apply_roles_to_object() so long as I am willing to accept the Roles overwriting the parent's methods in case of conflict (which is the opposite of a Role as far as I know, but I can live with it).

      Thanks for your reply.


      The way forward always starts with a minimal test.