On Fri Jun 08 11:50:14 2007, MSCHWERN wrote:
Show quoted text> Its not clear what using SUPER inside a trait's method will do. Looking
> at the tests it seems it will DWIM, it will start looking in the class
> which used the trait, but explicit docs would be nice.
Oh, it doesn't DWIM. I remember discussing this last you were in PDX.
Because the trait injects its code directly into the using class there's
no way for the trait user to define its own method. Therefore this will
not DWIM:
package TTest;
use Class::Trait 'base';
our @REQUIRES = qw(name);
sub name {
my $self = shift;
return "Name: ". $self->SUPER::name;
}
package Foo;
use Class::Trait "TTest";
sub new { bless {} }
sub name { "wibble" }
package main;
my $foo = Foo->new;
print $foo->name;
The use-case here is I have a set of ORDM functionality having to do
with transactions. Some of this has to override existing methods, for
example, update(). The trait user also might want to override the same
methods with their own extra stuff. Both the trait's update() and the
trait user's update() should run.
SUPER does not have to be the answer. Something like NEXT might also
work. But in order for it to work at all there has to be a way for the
trait and the trait user to have the same method defined.