in reply to Way to use Moo::Role to extend non-Moo class?
Then any class that consumes this role will be able to call the methods of foo that you set up delegation for.package bar; use Moo::Role; has 'foo' => ( is => 'rwp', handles => [qw/foo/], # put other methods to be delegated here );
If you were wanting to split up the methods into different roles, you could e.g. move the foo() method to its own role:
Then if bar wanted to 'extend' this with other methods:package Foo::Role; sub foo { print "foo\n"; }
package bar; use Moo::Role; with 'Foo::Role'; # ... other methods
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Way to use Moo::Role to extend non-Moo class?
by einhverfr (Friar) on Nov 13, 2013 at 11:07 UTC |