On 10/14/06 7:20 PM, James Masters wrote: > I'm trying to write generic code that will work for any table. [...] > > # construct manager name > my $classname = ucfirst($table); > chop($classname); > my $mgr = "GARD::".$classname."::Manager"; > > # Note: I was hoping to do > # use $mgr > # at this point but that doesn't work so I am having to "use" every class > manually at the start of the script. > > # construct method name > my $get_objects = "get_$table";
I think they key piece of knowledge you're missing is that a call like: $objs = My::Whatever::Manager->get_whatevers(...); is exactly equivalent to: $objs = Rose::DB::Object::Manager->get_objects( object_class => 'My::Whatever', ...); In other words, all the methods created for you in your *::Manager classes are trivial wrappers around Rose::DB::Object::Manager's get_objects() method, but with an object_class parameter value hard-coded. So if you want to generically query a table, and you know the name of the class of objects you want the call to return, you can simply call the get_objects() method directly on the class Rose::DB::Object::Manager (or any subclass of it, actually) and pass an explicit object_class parameter value. -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