Let's say I have a class Foo
with plugin traits/roles Bar
and Baz
, where Baz
is dependent on Bar
.
package Foo;
use Moose;
with 'MooseX::Traits';
sub foo {print "foo\n"}
package Bar;
use Moose::Role;
sub bar {
shift->foo;
print "bar\n";
}
package Baz;
use Moose::Role;
requires 'bar';
sub baz {
shift->bar;
print "baz\n";
}
package main;
my $foo = Foo->new_with_traits( traits => [qw/Bar Baz/] );
$foo->baz;
In this example, I've enforced the dependency with requires 'bar'
. However, what I want to do is for Baz
to require the entire role Bar
to enforce the dependency between the plugins.
Is there a simple way I can do this? Or do you have a suggestion for an alternative approach?