Bernhard Graf wrote: > In most cases I use the same inflator for multiple columns in a table. > So instead of calling inflate_column with the same attributes for each > column, I'd like to write > > __PACKAGE__->inflate_column(qw/col1 col2 col3/ => { > inflate => sub { Some:Class->inflate }, > deflate => sub { shift->deflate }, > }); > > Changes to inflate_column() would be easy and backwards-compatible, I > think. Simply rearranged the code a little bit, but didn't actually > tested: > > sub inflate_column { > my $self = shift; > my $attrs = pop; > $self->throw_exception("inflate_column needs attr hashref") > unless ref $attrs eq 'HASH'; > foreach my $col (@_) { > $self->throw_exception("No such column $col to inflate") > unless $self->has_column($col); > $self->column_info($col)->{_inflate_info} = $attrs; > $self->mk_group_accessors('inflated_column' => $col); > } > return 1; > } > > What do you think?
Personally, I'm not apposed to it, but it does leave a little bit to wonder in terms of assumin the last ar is a hashref... Riht now in Handel::Storae::DBIC, foreach column in currency_columns, I call inflate_column... I sure would mind this version so I could just pass in the list and be done with it.... I'd also be keen on an inflate_columns(qw/col1 col2 col3/ => { inflate => sub { Some:Class->inflate }, deflate => sub { shift->deflate }, )); instead.... -=Chris
signature.asc
Description: OpenPGP digital signature
_______________________________________________ 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/dbix-class@lists.rawmode.org/