Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I am not sure what you are asking here, are you looking for a trigger to be fired when C1 is reblessed into the anon-class?
I did not think of that. I was supposing that whatever function wrapped the "pull in an extension" would apply a trait to C1, and then look up $instance->c2 and $instance->c3 and apply traits to them too.

Basically, there are two approaches: (1) Create the extended class before creating the instance, and (2) Extend an existing instance.

With (2), I can extend all the collaborators at the same time, using only logic within the function that loads and applies the extension.

With (1), the extension of the top-level class needs to somehow change things so that when the collaborators are created, they are of the extended types too.

Without a rebless hook, (2) needs to be wrapped by my code so I does all the steps; it can certainly call "lower level" Role->meta->apply as well. My original question was wondering if these had some syntactic sugar or more mature incarnations in another module already done (like Perl 6 "but" feature).

But, I'm also supposing that I'm not breaking new ground in wanting an extension mechanism for a more complex case (not a single class, but functionality is broken up into smaller classes) and other people may have approached it already.

As for my aversion to needless instance data, something I saw in MooseX::Traits raises another question. But I'll start a new post for that.

Thanks for your patience.

—John


In reply to Re^4: Extensions via Moose by John M. Dlugosz
in thread Extensions via Moose by John M. Dlugosz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (3)
As of 2024-04-25 13:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found