note
Arunbear
What is the purpose of your bar package? If you wanted to reuse methods from package foo without refactoring foo itself, you could use method forwarding:
<code>
package bar;
use Moo::Role;
has 'foo' => (
is => 'rwp',
handles => [qw/foo/], # put other methods to be delegated here
);
</code>
Then any class that consumes this role will be able to call the methods of foo that you set up delegation for.
<p>
If you were wanting to split up the methods into different roles, you could e.g. move the foo() method to its own role:
</p>
<c>
package Foo::Role;
sub foo {
print "foo\n";
}
</c>
Then if bar wanted to 'extend' this with other methods:
<c>
package bar;
use Moo::Role;
with 'Foo::Role';
# ... other methods
</c>
1062361
1062361