[Dbix-class] "Alias" schema option

Christopher H. Laco claco at chrislaco.com
Mon Apr 3 19:13:39 CEST 2006


Christopher H. Laco wrote:
> While working on the Handel conversion to DBIC, I've come across the
> need to have my resultsets always be "Carts" and "Items" regardless of
> what the actual packages are named.
> 
> For now, I've simply created a register_cart_classes() method that calls
> register_class and sets the appropriate generic $monkier. Unfortunately,
> that means I can't use load_classes() and whatever magic it may contain.
> 
> Would there be any interest in adding something to ResultSource:
> 
> package My::Schema::Foo;
> __PACKAGE__->table('foo');
> __PACKAGE__->alias('Cart')
> # or
> __PACKAGE__->moniker('Cart');
> 
> 
> Then, after load_classes and connect(), we have:
> 
> $schema->resultset('Cart')...
> 
> instead of:
> 
> $schema->resultset('Foo')...

The only change is basically this to load_classes:

push(@to_register, [ $comp_class->moniker || $comp, $comp_class ]);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: OpenPGP digital signature
Url : http://lists.rawmode.org/pipermail/dbix-class/attachments/20060403/76946337/attachment-0001.pgp 


More information about the Dbix-class mailing list