Anyone else feel the related class  sub in Maypole::Model::CDBI should
be general and return the related class no matter what relationship? 
I guess so since the docs suggest it should.

I needed it to so i modified it. Here  it is in the flesh and it has
worked so far.

sub related_class {
    my ( $self, $r, $accessor ) = @_;
    my $meta = $self->meta_info;
    my @rels = keys %$meta;
    my $related;
    foreach (@rels) {
        $related = $meta->{$_}{$accessor};
        last if $related;
    }
    return unless $related;

    my $mapping = $related->{args}->{mapping};
    if ( $mapping and @$mapping ) { # bug was here : if (@$mapping) died
        return $related->{foreign_class}->meta_info('has_a')->{ $$mapping[0] }
          ->{foreign_class};
    }
    else {
        return $related->{foreign_class};
    }
}

Cheers,

Peter


-------------------------------------------------------
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

Reply via email to