[jifty-devel] [PATCH] Call isa() and can() as Methods

Jesse Vincent jesse at bestpractical.com
Wed Mar 15 14:39:08 EST 2006


chromatic wrote:
> On Tuesday 14 March 2006 14:59, jesse at bestpractical.com wrote:
> 
>> Sadly, it looks like we're missing Jifty core coverage for RightsFrom.
>> From our internal app:
>>
>> t/19-task-collection-acls.......Can't call method "isa" without a
>> package or object reference at
>> /usr/local/share/perl/5.8.7/Jifty/RightsFrom.pm line 113.
> 
> It looks like rearranging the if/else clauses to fail first if there's no 
> attribute of that name would clear up most of the problem.  Otherwise, the 
> standard eval { } trick around the method call will handle it.
> 

Turns out that the problem is slightly different than I thought:

The item that isa was being called on was an integer.

perl -e'my $x = 1; die unless $x->isa("Nonexistent::Class");'

The eval { } trick would certainly do, though it seems like

  perl -e'my $x = 1; die unless (ref $x and $x->isa("Nonexistent::Class"));'

is an order of magnitude faster and there are cases where this code
could be perfomrance critical. Am I missing a reason why this might not
be a clever thing to do?

There were a couple other cases where similar fixes were needed and one
case where there was a missing $ before a variable in the refactoring.

We're working hard to get the testsuite bits that are still locked up in
 BTDT migrated into Jifty.

Regardless, now I finally get to say "THANKS. Applied!"

I'd been meaning to get around to this refactoring for a while, but we
don't do Mock-based testing in-house, so I've got this longstanding bad
habit to break.

Jesse



> -- c
> _______________________________________________
> jifty-devel mailing list
> jifty-devel at lists.jifty.org
> http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel
> 


-------------- 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.bestpractical.com/pipermail/jifty-devel/attachments/20060315/e2c119ae/signature.pgp


More information about the jifty-devel mailing list