3

I am working on a MooX module that needs to add a wrapper around the constructor.

I've tried method modifies or having the import method directly change *{"${target}::new"} with no effect.

So how can I do this?

Rob
  • 781
  • 5
  • 19
  • Why can't you use BUILD? – choroba Dec 05 '14 at 13:18
  • 1
    Because I want to override whether it even returns an object of that type. It's a Moo version of [MooseX::Failover](https://metacpan.org/pod/MooseX::Failover). – Rob Dec 05 '14 at 13:20

1 Answers1

1

Apparently, around does work:

package MyRole;
use Moo::Role

around new => sub { ... };

but the role that has the around needs to be consumed after attributes are added, e.g.

package MyClass;
use Moo;

has attr1 => (... );
with 'MyRole';
Rob
  • 781
  • 5
  • 19