Subject: | Documentation error re:accessor_name_for() |
Date: | Wed, 14 Mar 2007 16:30:46 +0000 |
To: | bug-Class-DBI [...] rt.cpan.org |
From: | adam <adamlounds [...] gmail.com> |
http://search.cpan.org/~tmtm/Class-DBI-v3.0.16/lib/Class/DBI.pm#Changing_Your_Column_Accessor_Method_Names
The example code in the pod is
sub accessor_name_for {
my ($class, $column) = @_;
$column =~ s/^customer//;
return $column;
}
But accessor_name_for is passed a DBI::Class::Column object, which
stringifies to it name, not its accessor. If you override the column
using your own Class::DBI::Column (as documented in the section
immediately above this code), it doesn't work - the accessor method
isn't created (one is created for $column->name, but not one for
$column->accessor)
The example code should be something like
sub accessor_name_for {
my ($class, $column) = @_;
my $accessor = $column->accessor;
$accessor =~ s/^customer//;
return $accessor;
}
Thanks,
--
Adam