On 8/15/07, George Hartzell <[EMAIL PROTECTED]> wrote: > I'd like to get a count of the number of colors associated with a > widget. I know that I could just fetch them and count them, but I > thought that the relationship might provide a count method and now I'm > distracted by the generic question of guessing automagically generated > method names.
First, there is indeed a "count" method: http://search.cpan.org/dist/Rose-DB-Object/lib/Rose/DB/Object/Metadata/Relationship/ManyToMany.pm#METHOD_MAP but it's not created by default: http://search.cpan.org/dist/Rose-DB-Object/lib/Rose/DB/Object/Metadata/Relationship/ManyToMany.pm#default_auto_method_types so you'd have to add it explicitly: things => { type => 'many to many', ... add_methods => [ 'count' ], } (You could do the equivalent in a pre_init_hook, of course.) Second, there's no need to guess method names. Just ask: $method = My::Foo->meta->relationship('things')->method_name('count'); http://search.cpan.org/dist/Rose-DB-Object/lib/Rose/DB/Object/Metadata/Relationship.pm#method_name > how is it named? The answer to that should be here: http://search.cpan.org/dist/Rose-DB-Object/lib/Rose/DB/Object/Metadata/Relationship/ManyToMany.pm#build_method_name_for_type but I forgot to add it when I added the feature. I'll go fix it in SVN now. -John ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object