Skip Menu |

This queue is for tickets about the Class-Trait CPAN distribution.

Report information
The Basics
Id: 27504
Status: rejected
Priority: 0/
Queue: Class-Trait

People
Owner: Nobody in particular
Requestors: mschwern [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: Method generators + Class::Trait == no love
Consider the following. package TTest; use Class::Trait 'base'; use base qw(Class::Accessor); __PACKAGE__->mk_accessors(qw(foo)); 1; Doesn't work. It appears that Class::Trait considers foo() to be "imported" since the code ref was generated in another package. Compare with the following, which does work showing its not the run-time declaration. package TTest; use Class::Trait 'base'; *foo = sub { 42 } 1; The following does not work showing that it is, in fact, the code ref. package TTest; use Class::Trait 'base'; use base qw(Class::Accessor); __PACKAGE__->mk_accessors(qw(bar)); *foo = \&bar; 1; I don't know if this is fixable, but its worth noting as a caveat.
This becomes particularly important when you consider things like Class::DBI which creates accessor methods for each column and methods representing SQL statements. How would you make a trait which added a few columns (calls to columns()) and SQL statements (calls to set_sql())? package TTest; use Class::Trait 'base'; use base "Class::DBI"; # This makes sql_delete_yourself() and search_delete_yourself() TTest->set_sql( delete_yourself => <<'--' ); DELETE FROM __TABLE__ WHERE __IDENTIFIER__ -- # This makes this() and that() TTest->columns( Some_Group => qw(this that) ); 1;
Maybe a way for a trait to explicitly say "yes, really, make these methods part of the trait".
Rejected, sorry. As this module is deprecated, I'm hoping to have no more bug fixes after this. Cheers, Ovid