in reply to Re^5: Converting Moose object to a subclass of itself
in thread Converting Moose object to a subclass of itself

I would implore you to learn the base Perl way of generating objects in this case.

It appears to me as though you're losing out on a piece of the puzzle here. I do not mean to be disrespectful, but I think a peruse of perltoot and perlobj would really help.

Starting with something that wraps (ie. hides) the constructor (eg: Moose, Moo) may be hindering you from seeing what is truly possible.

An object can create an object of its own kind if designed properly, even with significantly different attributes and settings. You are not wanting to re-bless here, I assure you. You want to create either a same-object, or a sub-object depending on parameters sent in.

  • Comment on Re^6: Converting Moose object to a subclass of itself

Replies are listed 'Best First'.
Re^7: Converting Moose object to a subclass of itself
by nysus (Parson) on Feb 27, 2017 at 01:05 UTC

    OK, I will re-read those (it's been many moons since I've looked at them and I will probably get a lot more out of them now that I have at least a bit of a clue). I agree that conceptually I don't know enough to ask the proper question here or understand your answers. In the meantime, I have successfully been able to use the rebless_instance method to achieve what I want. Admittedly, it's a confusing mess. :) Thanks for your time and confirming that I'm likely going down the wrong path. It does help me.

    $PM = "Perl Monk's";
    $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate";
    $nysus = $PM . ' ' . $MCF;
    Click here if you love Perl Monks

      I can't speak for all of us, but for me personally, I feel you're doing a great job asking questions and digging deeper with all you do.

      Perlmonks needs people like you, because they feed people like me (and others), as this generates interesting topics. This spurs conversations where even the most knowledgeable monks pick up new things.

      Keep up with the good work, nysus, and do as I do... if you have a question, never be afraid to ask, and just ask it.

        By the way, I think you were the one who convinced me about the merits of testing my code last year. I'm loving it, especially when I decide to rewrite a big chunk of code. It makes it so much easier to fix problems. So thanks for that.

        $PM = "Perl Monk's";
        $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate";
        $nysus = $PM . ' ' . $MCF;
        Click here if you love Perl Monks

        Don't worry about me, I've never been afraid of asking questions. My brain works in mysterious ways. I think it uses a brute force mechanism. But once it latches onto something, there's no stopping it. :) Thanks for the encouragement.

        $PM = "Perl Monk's";
        $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate";
        $nysus = $PM . ' ' . $MCF;
        Click here if you love Perl Monks