[Dbix-class] RFC: DBICx::Shortcuts

fREW Schmidt frioux at gmail.com
Thu Feb 4 18:53:20 GMT 2010


On Mon, Jan 18, 2010 at 7:02 AM, Pedro Melo <melo at simplicidade.org> wrote:

> Hi,
>
> I've cleaned up and uploaded to CPAN a small module that I use a lot in my
> code.
>
> I got tired of writting
>
> $schema->resultset('Source')->....
>
> all the time, and I wrote DBICx::Shortcuts.
>
> You create a new class (I usually give it a very small name, like
> MyApp::S, tweak MyApp to taste), as a subclass of DBICx::Shortcuts and
> link it to a Schema class with a setup('MyApp::Schema') call.
>
> For each source, it creates a shortcut method in your class. So I can
> write:
>
> MyApp::S->source->...
>
> As a bonus, you can also call
>
> MyApp::S->source($id)
>
> as a shortcut to
>
> $schema->resultset('Source')->find($id)
>
> All other calls to the source() shortcut with parameters will end up
> as calls to search().
>
> Comments, suggestions?
>

It may be too late at this point, but DBICx is not the preferred namespace.
 Typically we use DBIx::Class::Foo instead.

Also, you basically made a global schema if I'm reading this right.  This is
just one schema at a time by design then?  Because sometimes it's great that
we can have the same schema connected to more than one db at once...
-- =

fREW Schmidt
http://blog.afoolishmanifesto.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20100204/8e9=
5d4dc/attachment.htm


More information about the DBIx-Class mailing list