in reply to Re^2: Moose: creating sub-classes on the fly
in thread Moose: creating sub-classes on the fly

Well, I guess that depends on how the inherited meta behaves. If you want to be sure to have all that overhead, you could use
for my $error_type (qw( Unrecoverable Unrecoverable::BrainDamage )) { eval(" package MonkeyMan::Error::$error_type; use Moose; extends 'MonkeyMan::Error'; 1 ") or die $@; }

Replies are listed 'Best First'.
Re^4: Moose: creating sub-classes on the fly
by tobyink (Canon) on Oct 10, 2014 at 21:36 UTC

    As documented in Moose, you don't actually inherit the meta method from Moose::Object. Each Moose class gets its own individual meta method built for it, completely overriding any that would have been inherited.

    They're all much of a muchness though:

    sub meta { $metaclass->initialize(blessed($_[0]) || $_[0]); }

    The $metaclass variable which has been closed over is usually the string "Moose::Meta::Class", though it may be a different class name if you're doing interesting metaprogramming stuff.

      As documented in Moose, you don't actually inherit the meta method from Moose::Object.

      I never said it was inherited from Moose::Object. The code in question inherits the method from MonkeyMan::Error.