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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.