[Dbix-class] Class methods on result source classes
Matt S Trout
dbix-class at trout.me.uk
Mon Sep 3 20:24:25 GMT 2007
On Mon, Sep 03, 2007 at 01:22:49PM +0100, Pedro Melo wrote:
> I'm using a "fat model" approach in a small project and one thing
> that keeps popping up is class methods.
> For example, I usually have a can_edit() method in a base class that
> all my sources use. This allows me to do something like this:
> The can_edit() method will receive as "self" the Book with the $id,
> and it will just work.
> But if I want to write a can_create(), I do something like:
> or like this
> The second one is longer but easier to do because it doesn't require
> me to create a ResultSet class for each source.
> Any common, more elegant, solution to this problems?
Creating the resultset class is both correct and elegant.
See load_namespaces for a way to save a bit of typing.
Matt S Trout Need help with your Catalyst or DBIx::Class project?
Technical Director Want a managed development or deployment platform?
Shadowcat Systems Ltd. Contact mst (at) shadowcatsystems.co.uk for a quote
More information about the DBIx-Class