On 9/11/05, Frank Carnovale
<[EMAIL PROTECTED]> wrote:
> Peter,
>
> The original related_class method looked like an unfinished experiment to me,
> and yes it is badly named because it confines itself to has_many's only.
>
> If it's any help, here is a chunk from our application model class which I
> coded earlier this year. I vaguely remember discovering that related_class
> as it stood then was broken and also never used anywhere, so I fixed it and
> kept on bravely not using it.
> Right now I would have to invest serious time trying to re-learn both the
> original code and my alleged fix, which involved quite a bit of Class::DBI
> digging. So I can't make any useful comment right now about why I thought it
> was broken and why my version was any better, but here it is..
> ###########################
> # override this Maypole::Model::CDBI method which is broken there, but never
> used.
> sub related_class {
> my ( $self, $accessor ) = @_;
> my $meta_has_many = $self->meta_info('has_many') || return;
> my $meta_accessor = $meta_has_many->{$accessor} || return;
> my $mapping = $meta_accessor->{args}->{mapping} || [];
> return
> $meta_accessor->{foreign_class}->meta_info('has_a')->{$$mapping[0]}->{foreign_class}
> if @$mapping;
> return $meta_accessor->{foreign_class};
> }
> ############################
>
Hi. Thanks Frank. I see you fixed the @$mapping bug. The cuurent
version uses @$mapping without defining it with an "|| [] " first. So
if you call related_class with a has_a accessor it will die.
Yours only works for has_many. I like it to work for any , including
custom ones.
cheers.
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Maypole-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/maypole-devel