There's a nice snippet in the Perl Cookbook regarding this:
@colors = qw(red blue green yellow orange purple violet);
for my $name (@colors) {
no strict 'refs';
*$name = sub { "<FONT COLOR='$name'>@_</FONT>" };
}
Mike Friedman wrote:
On 10/30/06, A. Pagaltzis <[EMAIL PROTECTED]> wrote:
This ain't Java.
my @table_class = qw( MyTable MyTable2 );
for my $t ( @table_class ) {
*$t = sub { $_[0]->resultset( $t ) };
}
You have to turn strict references off to do that, of course. (You
_DO_ have strict on, right? :) )
This is basically what I ended up doing in my schema class, by looping
over __PACKAGE__->sources.
I also exported the methods, as per Dan's suggestion, so I can use
them as mixins in my webapp object.
Thanks for all the help and discussion, everyone. I think I've got a
handle on things now.
Mike
_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive:
http://www.mail-archive.com/[email protected]/
_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/[email protected]/