Since I have a current DBIC working copy on my HD now, I also offer this 
patch to be applied. It lets you set an inflator for multiple columns 
at once, as described in my email one month ago:
http://lists.scsys.co.uk/pipermail/dbix-class/2006-October/002687.html

-- 
Bernhard Graf
--- DBIx/Class/InflateColumn.pm	(revision 2947)
+++ DBIx/Class/InflateColumn.pm	(working copy)
@@ -31,18 +31,18 @@
 
 =head2 inflate_column
 
-Instruct L<DBIx::Class> to inflate the given column.
+Instruct L<DBIx::Class> to inflate the given columns.
 
-In addition to the column name, you must provide C<inflate> and
+In addition to the column names, you must provide C<inflate> and
 C<deflate> methods. The C<inflate> method is called when you access
 the field, while the C<deflate> method is called when the field needs
 to used by the database.
 
-For example, if you have a table C<events> with a timestamp field
-named C<insert_time>, you could inflate the column in the
-corresponding table class using something like:
+For example, if you have a table C<events> with two timestamp fields
+named C<insert_time> and C<update_time>, you could inflate the columns
+in the corresponding table class using something like:
 
-    __PACKAGE__->inflate_column('insert_time', {
+    __PACKAGE__->inflate_column('insert_time', 'update_time', {
         inflate => sub { DateTime::Format::Pg->parse_datetime(shift); },
         deflate => sub { DateTime::Format::Pg->format_datetime(shift); },
     });
@@ -55,20 +55,23 @@
 row object itself. Thus you can call C<< ->result_source->schema->storage->dbh >> on
 it, to feed to L<DateTime::Format::DBI>.
 
-In this example, calls to an event's C<insert_time> accessor return a
-L<DateTime> object. This L<DateTime> object is later "deflated" when
+In this example, calls to an event's C<insert_time> or C<update_time> accessor
+return a L<DateTime> object. This L<DateTime> object is later "deflated" when
 used in the database layer.
 
 =cut
 
 sub inflate_column {
-  my ($self, $col, $attrs) = @_;
-  $self->throw_exception("No such column $col to inflate")
-    unless $self->has_column($col);
+  my $self = shift;
+  my $attrs = pop;
   $self->throw_exception("inflate_column needs attr hashref")
     unless ref $attrs eq 'HASH';
-  $self->column_info($col)->{_inflate_info} = $attrs;
-  $self->mk_group_accessors('inflated_column' => $col);
+  for (@_) {
+    $self->throw_exception("No such column $_ to inflate")
+      unless $self->has_column($_);
+    $self->column_info($_)->{_inflate_info} = $attrs;
+    $self->mk_group_accessors('inflated_column' => $_);
+  }
   return 1;
 }
 
_______________________________________________
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/

Reply via email to