On 3/9/07, Peter Karman <[EMAIL PROTECTED]> wrote:
> But I don't get this magical method:
>
> $product->delete_prices($price_id);
>
> which would be equivalent to:
>
> sub delete_prices
> {
> my $self = shift; # Product
> my $price_id = shift;
>
> my @keep = grep { $_->id ne $price_id } $self->prices;
> $self->prices(@keep);
> }
>
Yeah, there's no individual delete methods for ...-to-many
relationships yet. What you're written above amounts to a simple
implementation of a "delete_on_save" method (but only if prices() is a
"get_set_on_save" method; a real implementation wouldn't be able to
rely on this).
Such things are on my (long) to-do list.
> Maybe I'm missing some (obvious) item in the (otherwise exhaustive)
> documentation about this? I was looking specifically for a list of all the
> default method names created when a relationship is defined between two RDBO
> classes.
Each relationship class (or fk, same thing for our purposes here) has
a "method map" in its docs that describes the possible method types
for that relationship. You can find a description of relationship
methods and the method maps in the relationship base class docs:
http://search.cpan.org/dist/Rose-DB-Object/lib/Rose/DB/Object/Metadata/Relationship.pm#MAKING_METHODS
Here's the method map for one-to-many relationships. (Each one links
to further docs describing the method.)
http://search.cpan.org/dist/Rose-DB-Object/lib/Rose/DB/Object/Metadata/Relationship/OneToMany.pm#METHOD_MAP
Those are all the *possible* method types. By default, only the
method types returned by the default_auto_method_types() method are
created. Example:
http://search.cpan.org/dist/Rose-DB-Object/lib/Rose/DB/Object/Metadata/Relationship/OneToMany.pm#default_auto_method_types
So, for a one-to-many relationship, the "find", "get_set_on_save", and
"add_on_save" method types are created by default.
Finally, to find out what those methods will be called, look at the
docs for the build_method_name_for_type() method. Example:
http://search.cpan.org/dist/Rose-DB-Object/lib/Rose/DB/Object/Metadata/Relationship/OneToMany.pm#build_method_name_for_type
The loose coupling makes for a lot of flexibility, but it also makes
for widely separated docs, I know. Some sort of summary or overview
would probably be handy, but I haven't gotten around to it.
-John
-------------------------------------------------------------------------
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