[Dbix-class] DBIx::Class::SingletonRows

Jonathan Rockway jon at jrock.us
Mon Jun 30 17:36:33 BST 2008


* On Wed, Jun 25 2008, David Cantrell wrote:
> I got permission from my boss, and DBIx::Class::SingletonRows is now
> wending its merry way through the PAUSE and out to CPAN mirrors.

I like this.  People are constantly whining how singleton rows or
non-singleton rows are the One True Way, and everything that disagrees
with them is WRONG!!11!  Now users of DBIC can pick for themselves
instead of being told what to think :) (FWIW, I am on the non-singleton
row side of things. :)

> Unlike the earlier versions, this one is a proper component and is only
> slightly magical.

Looks good, but I'm a bit unclear on this part:

> sub magick_object {
>     my $object = shift;
>     my $class  = ref($object);
>     (my $newclass = q[
>         package DBIx::Class::SingletonRows::Cached::$class;
>         use strict;
>         use Digest::MD5 qw(md5_hex);
>         use Scalar::Util qw(refaddr);
>         use vars qw($AUTOLOAD);
> 
>         # use base qw($class); # faked up by the following two lines ...
>         sub can { return $class->can($_[1]); }
>         sub isa { return $class->isa($_[1]); }
> 
>         sub AUTOLOAD {
>             (my $sub = $AUTOLOAD) =~ s/.*:://;
>             my $self = shift;
>             $self->{_obj}->$sub(@_);
>         }
> 

Is there a reason why you have to fake inheritance here?  All the
methods dispatch to "$obj", and isa and can say they are "ref $obj", so
I'm confused as to why your pseudo-subclass isn't just a real subclass.

Perhaps I'm missing something, but I think other people are probably
wondering the same thing.  (As an aside, whenever you have to have a
long comment explaining why you do something, it's probably not the best
approach ;)

Regards,
Jonathan Rockway

-- 
print just => another => perl => hacker => if $,=$"



More information about the DBIx-Class mailing list