--- John Siracusa <[EMAIL PROTECTED]> wrote:
> sub add_columns
> {
> my($self) = shift;
>
> my @added_columns = $self->SUPER::add_columns(@_);
>
> foreach my $column (@added_columns )
> {
> $self->alias_column($column->name => '_' . $column->name)
> unless($self->class->is_public($column));
> }
>
> return @added_columns ;
> }
>
> (The return value for add_columns() wasn't documented, but has always
> been the list of columns just added. It's documented in SVN.)
I've gotten this to work. One problem is that the return value of
add_columns() is actually the new number of columns in the
'columns_ordered' attribute, not the columns themselves:
push(@{$self->{'columns_ordered'}}, @columns);
That's the last line of add_columns(). The following handles this:
sub add_columns {
my $self = shift;
$self->SUPER::add_columns(@_);
foreach my $column ( $self->columns ) {
$self->alias_column( $column->name => '_' . $column->name )
unless ( $self->class->is_public_method($column) );
}
return scalar $self->columns;
}
To be fair, I'm going to have to alter even this. I've realized that
I'm making my public accessors too tied to the database column names.
What I really need to do is this:
sub add_columns {
my $self = shift;
$self->SUPER::add_columns(@_);
foreach my $column ( $self->columns ) {
$self->alias_column(
$column->name => $self->class->public_column_name($column)
);
}
return scalar $self->columns;
}
Cheers,
Ovid
--
Buy the book -- http://www.oreilly.com/catalog/perlhks/
Perl and CGI -- http://users.easystreet.com/ovid/cgi_course/
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Rose-db-object mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rose-db-object