Hi Monks, Trying to use override with my Moose::Role doesn't work if I am overriding a parent role's implementation.
package top; use Moose::Role; requires 'token'; sub foo { print "foo\n"; } sub useful_method{ print "I'm useful\n" } package bottom; use Moose::Role; with 'top'; override 'foo' => sub { print "bar\n"; }; package something; use Moose; with "bottom"; sub token { print "implement me in the concrete class"; } package main; my $something = new something; $something->foo;
Gives "Cannot add an override of method 'foo' because there is a local version of 'foo'". Just putting a normal sub instead of override doesn't work etither. I get: "Due to a method name conflict in roles 'bottom' and 'top', the method 'foo' must be implemented or excluded by 'something'". Basically the problem is: I want to use top's useful_method and bottom's foo and I don't want to implement "token" until the concrete class. Why can't I use Roles in this way?
Thanks!In reply to Moose Roles and Override by edwinorc
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |