Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is an equivalent of MooseX::NonMoose for Moo?

Tags:

oop

perl

I would like to use Moo instead of Moose, but I also need to inherit from non-Moose classes. How should I deal with that? Is there a module to work around this? If not, is there a way I can handle it myself?

like image 458
user4373782 Avatar asked Dec 18 '14 10:12

user4373782


1 Answers

Moo can handle subclassing non-Moo/Moose classes already. You don't need an extension.

See the documentation for FOREIGNBUILDARGS, which states:

If you are inheriting from a non-Moo class, the arguments passed to the parent class constructor can be manipulated by defining a FOREIGNBUILDARGS method. It will receive the same arguments as BUILDARGS, and should return a list of arguments to pass to the parent class constructor.

like image 109
tobyink Avatar answered Oct 22 '22 10:10

tobyink