Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^5: Problem generating builder functions with Moose for inherited objects

by tospo (Hermit)
on Sep 02, 2010 at 12:55 UTC ( [id://858564]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Problem generating builder functions with Moose for inherited objects
in thread Problem generating builder functions with Moose for inherited objects

Would it not be better to use proper Moose roles now that you are converting this to Moose? Otherwise I would really be wondering what you gain from the conversion? Sorry, I know you probably thought about all of this and I know it's a bit annoying when you ask a question and people start preaching "the one true path" at you but sometimes it may also helpful to run your reasoning past another person to arrive at new solutions...

Anyway, I think the Moose documentation is not contradicting the observed (and probably expected) behaviour. Yes, the parent's BUILD method is called but the object is still of class "Child", not "Parent". It's like calling $self->SUPER::BUILD (which you shouldn't) - you call an inherited METHOD but the object you call it on doesn't change class, if that makes any sense?
The fact that you get "Parent" from __PACKAGE__ doesn't mean that the object is of that class - it just means that this method is defined in the file that defines package "Parent".

  • Comment on Re^5: Problem generating builder functions with Moose for inherited objects

Replies are listed 'Best First'.
Re^6: Problem generating builder functions with Moose for inherited objects
by Neighbour (Friar) on Sep 02, 2010 at 14:38 UTC
    The idea was to use proper Moose roles, but I got sidetracked at the point where I used lazy_build=>1 and still had to generate builder-functions.

    I could fill you in on the details of the getup, but it would be inappropriate to do so in this thread.

    Besides that, your reasoning on $self rings true :)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (9)
As of 2024-04-23 07:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found