[Dbix-class] Feature request for DBIx::Class::InflateColumn::inflate_column

Christopher H. Laco claco at chrislaco.com
Fri Oct 27 23:02:04 BST 2006


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/ =3D> {
>     inflate =3D> sub { Some:Class->inflate },
>     deflate =3D> 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 =3D shift;
>   my $attrs =3D 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} =3D $attrs;
>     $self->mk_group_accessors('inflated_column' =3D> $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/ =3D> {
     inflate =3D> sub { Some:Class->inflate },
     deflate =3D> sub { shift->deflate },
));

instead....

-=3DChris

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: OpenPGP digital signature
Url : http://jules.scsys.co.uk/pipermail/dbix-class/attachments/20061027/80=
ab6e22/signature.pgp


More information about the DBIx-Class mailing list