[Dbix-class] "Alias" schema option

Christopher H. Laco claco at chrislaco.com
Mon Apr 3 19:15:45 CEST 2006


Christopher H. Laco wrote:
> 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 ]);
> 
> 

And of course, adding an moniker/alias accessor to ResultSource(Proxy)...

-------------- 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/de20f308/attachment.pgp 


More information about the Dbix-class mailing list