I'm trying to use DBIx::Class::AccessorGroup to make an accessor that
trims field values, as discussed in another thread. Since I want to use
this accessor with many tables, I want to define the code in some
package that is used for all the tables. But I can't figure out where to
put it and I'm getting confused about base classes.
So for example I have a table NewDomainSegment and I have code like this:
package SU::Schema::NewDomainSegment;
use base 'SU::Schema';
__PACKAGE__->load_components(qw/AccessorGroup Core/);
__PACKAGE__->mk_group_ro_accessors( trim => qw/sprot_ac/ );
and in SU::Schema, I have:
sub get_trim
{
my ($self, $column) = @_;
my $raw_value = $self->get_column($column);
$raw_value =~ /^\s*(.*?)\s*$/;
my $trimmed_value = $1;
return $trimmed_value;
}
but it's not working; SU::Schema::NewDomainSegment->can('get_trim') is
undefined. Is SU::Schema the right place to put the implementation of
get_trim?
Thanks, Dave
_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/[email protected]/