On 7/14/06 7:56 PM, Danial Pearce wrote: > I have tried a few different things, all of which I can get to work. > > __PACKAGE__->auto_init_columns; > for (__PACKAGE__->meta->columns) { > __PACKAGE__->meta->column($_)->auto_method_types('get', 'set'); > __PACKAGE__->meta->column($_)->method_name(get => "get$_"); > __PACKAGE__->meta->column($_)->method_name(set => "set$_"); > } > __PACKAGE__->initialize; > > The above works. I can also edit the My::Metadata class to overload > the auto_generate_column() method to effectively do the above for me. > > I'm wondering if either of the strategies I am using here are > considered "the right way".
Overriding auto_generate_column() in your custom metadata class is probably the cleanest approach. sub auto_generate_column { my $column = shift->SUPER::auto_generate_column(@_); $column->add_auto_method_types('get', 'set'); $column->method_name(get => 'get' . $column->name); $column->method_name(set => 'set' . $column->name); return $column; } Notice that I called add_auto_method_types() instead of auto_method_types(). It's worthwhile to leave the default "get_set" method type in there, if only as yet another way to refer to a column in a Manager query. > Is there a way I can tell convention manager what the convention is for > naming the accessors and mutators? No, not really. Just various places where you can reach in and basically do what's shown above. > If there isn't a way, and people think there should be, I'd be happy > to work on a patch. You're welcome to it! But it's probably a good idea to hash out the API on the list before you start actual coding. Remember that you're not just deciding how to name methods. You're also deciding which method types will be created in the first place. So I think there are two new areas for convention manager intervention: 1. "Thingie" name to method name mapping for a given method type. 2. Determining the list of method types for each "thingie." ...where "thingie" is a column, foreign key, or relationship. You can probably just start by doing columns, but it's a good idea to keep the other things in mind. -John ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Rose-db-object mailing list Rose-db-object@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rose-db-object