added column attributes to generated POD
Robert Buels [Fri, 1 Jan 2010 21:54:22 +0000 (21:54 +0000)]
lib/DBIx/Class/Schema/Loader/Base.pm
t/12pg_common.t

index 721816c..e572331 100644 (file)
@@ -1241,14 +1241,27 @@ sub _dbic_stmt {
         $self->_pod_cut( $class );
     } elsif ( $method eq 'add_columns' ) {
         $self->_pod( $class, "=head1 ACCESSORS" );
-        my $i = 0;
-        foreach ( @_ ) {
-            $i++;
-            next unless $i % 2;
-            $self->_pod( $class, '=head2 ' . $_  );
-            my $comment;
-            $comment = $self->_column_comment( $self->{_class2table}{$class}, ($i - 1) / 2 + 1  ) if $self->can('_column_comment');
-            $self->_pod( $class, $comment ) if $comment;
+        my $col_counter = 0;
+       my @cols = @_;
+        while( my ($name,$attrs) = splice @cols,0,2 ) {
+           $col_counter++;
+            $self->_pod( $class, '=head2 ' . $name  );
+           $self->_pod( $class,
+                        join "\n", map {
+                            my $s = $attrs->{$_};
+                            $s = !defined $s      ? 'undef'          :
+                                 length($s) == 0  ? '(empty string)' :
+                                                     $s;
+
+                            "  $_: $s"
+                        } sort keys %$attrs,
+                      );
+
+           if( $self->can('_column_comment')
+               and my $comment = $self->_column_comment( $self->{_class2table}{$class}, $col_counter)
+             ) {
+               $self->_pod( $class, $comment );
+           }
         }
         $self->_pod_cut( $class );
     } elsif ( $method =~ /^(belongs_to|has_many|might_have)$/ ) {
index 963ba0d..dd4412a 100644 (file)
@@ -44,8 +44,8 @@ my $tester = dbixcsl_common_tests->new(
             like $code, qr/^=head1 NAME\n\n^$class - The Table\n\n^=cut\n/m,
                 'table comment';
 
-            like $code, qr/^=head2 value\n\nThe Column\n\n/m,
-                'column comment';
+            like $code, qr/^=head2 value\n\n(.+:.+\n)+\nThe Column\n\n/m,
+                'column comment and attrs';
         },
     },
 );