Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^3: Moose: creating sub-classes on the fly

by ikegami (Patriarch)
on Oct 10, 2014 at 17:06 UTC ( [id://1103447]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1103447]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-25 06:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found