Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Maintaining State with Runtime Traits

by jdhedden (Deacon)
on Oct 11, 2006 at 19:39 UTC ( [id://577706]=note: print w/replies, xml ) Need Help??


in reply to Maintaining State with Runtime Traits

Interesting. Your Trait::Selected class looks very much like an inside-out class. In fact, using Object::InsideOut it could be implemented, very simply, as follows:
package Trait::Selected; use Object::InsideOut; my %is_selected :Field :Acc(is_selected);
(Of course, looking at Class::Trait, I see that it offers a lot of functionality beyond that covered by my simple example above.)
Class::Trait->apply( $some_class, 'Trait::Selected' );
Ah, sweet synergy! This prompted me to add a runtime inheritance mechanism to Object::InsideOut:
My::Class->add_class('Trait::Selected');
What happens when the object goes out of scope? The trait still retains that object’s selected value and it’s tricky to remove.
If done using Object::InsideOut, this is no issue at all: The trait will be automatically cleaned up when an object is destroyed.

I just uploaded Object::InsideOut v2.08 (which contains the runtime inheritance feature) to CPAN. Thanks for the idea.


Remember: There's always one more bug.

Replies are listed 'Best First'.
Re^2: Maintaining State with Runtime Traits
by Ovid (Cardinal) on Oct 11, 2006 at 21:07 UTC

    Bink! That piques my interest. Can't wait to see it out there and I'll start playing with it. Maybe that's enough to get me over the learning curve hurdle. Thanks!

    Cheers,
    Ovid

    New address of my CGI Course.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-03-28 22:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found