[Dbix-class] DBIx::Class::AccessorGroup

Dave Howorth dhoworth at mrc-lmb.cam.ac.uk
Tue Mar 6 14:08:00 GMT 2007


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



More information about the Dbix-class mailing list