From: Ken Youens-Clark Date: Fri, 6 Jun 2003 22:35:44 +0000 (+0000) Subject: Added parsing of comments on init, added "comments" method. X-Git-Tag: v0.02~74 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5ac417adbb673979926d71245f54d317c0b3a152;p=dbsrgits%2FSQL-Translator.git Added parsing of comments on init, added "comments" method. --- diff --git a/lib/SQL/Translator/Schema/Field.pm b/lib/SQL/Translator/Schema/Field.pm index ae925f2..4ed5fcb 100644 --- a/lib/SQL/Translator/Schema/Field.pm +++ b/lib/SQL/Translator/Schema/Field.pm @@ -1,7 +1,7 @@ package SQL::Translator::Schema::Field; # ---------------------------------------------------------------------- -# $Id: Field.pm,v 1.6 2003-06-06 00:09:25 kycl4rk Exp $ +# $Id: Field.pm,v 1.7 2003-06-06 22:35:44 kycl4rk Exp $ # ---------------------------------------------------------------------- # Copyright (C) 2003 Ken Y. Clark # @@ -70,7 +70,7 @@ Object constructor. for my $arg ( qw[ table name data_type size is_primary_key is_nullable - is_auto_increment default_value + is_auto_increment default_value comments ] ) { next unless defined $config->{ $arg }; @@ -81,6 +81,33 @@ Object constructor. } # ---------------------------------------------------------------------- +sub comments { + +=pod + +=head2 comments + +Get or set the comments on a field. May be called several times to +set and it will accumulate the comments. Called in an array context, +returns each comment individually; called in a scalar context, returns +all the comments joined on newlines. + + $field->comments('foo'); + $field->comments('bar'); + print join( ', ', $field->comments ); # prints "foo, bar" + +=cut + + my $self = shift; + push @{ $self->{'comments'} }, @_ if @_; + + return wantarray + ? @{ $self->{'comments'} || [] } + : join( "\n", @{ $self->{'comments'} || [] } ); +} + + +# ---------------------------------------------------------------------- sub data_type { =pod