[Dbix-class] many to many set_$rel return value

Richard Jolly Richard.Jolly at bbc.co.uk
Mon Mar 5 18:28:06 GMT 2007


Hi,

I need to do  what set_$rel accomplishes on a many to many relationship.
But I have the additional requirement that I need to know if any items
have changed. 

One implementation is something like this:

sub set_version_types {
    my ($self, at types) = @_;

   # or could use Set::* modules
    my $existing = join '-', sort map { $_->public_id }
$self->version_types;
    my $new      = join '-', sort map { $_->public_id } @types;

    return 0 if $existing eq $new;

    $self->next::method(@types);

    return 1;

}

But I'd like this on generically - eg on all many to many rels. I could
subclass Relationship::ManytoMany, but it's one big method in there.

So my questions are: how best to do this generically, and is a solution
to this useful for DBIC in general?

Thanks,

Richard J.


http://www.bbc.co.uk/
This e-mail (and any attachments) is confidential and may contain personal views which are not the views of the BBC unless specifically stated.
If you have received it in error, please delete it from your system.
Do not use, copy or disclose the information in any way nor act in reliance on it and notify the sender immediately.
Please note that the BBC monitors e-mails sent or received.
Further communication will signify your consent to this.
					



More information about the Dbix-class mailing list