[Dbix-class] get_columns/get_inflated_columns
Matt S Trout
dbix-class at trout.me.uk
Mon May 21 18:26:18 GMT 2007
On Mon, May 21, 2007 at 10:17:21AM -0400, Christopher H. Laco wrote:
> Msts Vox post about monkey patching reminded me this morning that I
> needed to put this somewhere:
>
> > *DBIx::Class::Row::get_inflated_columns =3D sub {
> > my $self =3D shift;
> >=20
> > return map {$_ =3D> $self->$_} $self->columns;
> > };
>
>
> I stuffed it into my DBIC provider just to try it on for size.
>
> Now, I can put this into a base class and have all my schema classes
> inherit from that. Sure, it's so easy, a cave man can do it. But I'm not
> the first, nor will I be the last to write these three lines of code and
> inherit a base classes for source classes just to do this very thing.
>
> Can we just put this in DBIC already?
Sure, but it has to obey ->{accessor} (and you'll need to patch inflate_column
to while you're there) and there'll need to be tests.
Oh, and how do you propose to handle people wanting rels as well?
Or non-column attributes? (c.f. Oleg's horrible hack because he wanted to
use get_columns on non-column things)
--
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
http://chainsawblues.vox.com/ http://www.shadowcatsystems.co.uk/
More information about the Dbix-class
mailing list