Ash Berlin wrote: > Dave Howorth wrote: >> Will Hawes wrote: >>> On 05/03/07, Dave Howorth <[EMAIL PROTECTED]> wrote: >>>> I need to read data from a database where fields have been entered by >>>> hand and have miscellaneous extraneous leading and trailing whitespace. >>>> >>>> I think the best approach is to suppress these characters as I retrieve >>>> the fields from the database, so I guess I need to override some method >>>> (in my Schema ?) but I haven't figured out which. >>>> >>>> I've looked around in the Cookbook and FAQ without spotting anything. >>>> Could somebody give me a pointer to the right place? >>>> >>>> Thanks, Dave >>> Wouldn't you just override the relevant accessors in your model >>> classes to do this? >> >> I'm not quite sure what 'model classes' means in this context? I don't >> think I want to override individual accessors; I think I want to >> override whatever they inherit from (the equivalent of CDBI's get() >> method). I just don't know where to read up about how to do that. >> >> Cheers, Dave >> > > > If you really want to do it that way - look at Inflators.
Where are they? I can't find the word inflator in the dozen or so DBIC POD pages I've got open except at <http://search.cpan.org/~jrobinson/DBIx-Class-0.07005/lib/DBIx/Class/Manual/Cookbook.pod#Overloading_methods> The only place the word inflator appears in the code base is in DBIx/Class/InflateColumn.pm. Do you mean to use inflate_column? That also looks like it has to be done column-by-column? I'm looking for a place to hook into the main retrieval path. > What Will was talking about was adding something like the following: > > sub my_col { > my ($self) = shift; > > if (@_) > return my_trim($self->next::my_col); > > $self->next::my_col(my_trim(@_)); I guess that should be something like return $self->next::my_col(my_trim(@_)) if @_; return my_trim($self->next::my_col); > } > > In your ResultSource classes. But there are 31 tables with about ten columns per table. I'd rather not write 300 or so identical methods! That's why I'm looking for a central point. 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]/
