From: <chr...@us...> - 2006-03-22 00:32:50
|
Revision: 837 Author: chromatic Date: 2006-03-21 16:32:27 -0800 (Tue, 21 Mar 2006) ViewCVS: http://svn.sourceforge.net/everydevel/?rev=837&view=rev Log Message: ----------- Rewrote UNIVERSAL::isa() and UNIVERSAL::can() calls to their method forms. Modified Paths: -------------- trunk/ebase/Build.PL trunk/ebase/lib/Everything/HTML/FormObject/PermissionMenu.pm trunk/ebase/lib/Everything/Mail.pm trunk/ebase/lib/Everything/Node/node.pm trunk/ebase/lib/Everything/Node/nodeball.pm trunk/ebase/lib/Everything/Node/nodegroup.pm trunk/ebase/lib/Everything/NodeBase.pm trunk/ebase/lib/Everything.pm trunk/ebase/t/HTML/Datetime.t trunk/ebase/t/HTML/FormObject/AuthorMenu.t trunk/ebase/t/HTML/FormObject/ListMenu.t trunk/ebase/t/HTML/FormObject/NodetypeMenu.t trunk/ebase/t/NodeBase.t Modified: trunk/ebase/Build.PL =================================================================== --- trunk/ebase/Build.PL 2006-03-22 00:18:23 UTC (rev 836) +++ trunk/ebase/Build.PL 2006-03-22 00:32:27 UTC (rev 837) @@ -34,6 +34,7 @@ 'File::Spec' => 0.82, 'Mail::Address' => 1.53, 'Mail::Sender' => 0, + 'Scalar::Util' => 1.01, }, build_requires => { Modified: trunk/ebase/lib/Everything/HTML/FormObject/PermissionMenu.pm =================================================================== --- trunk/ebase/lib/Everything/HTML/FormObject/PermissionMenu.pm 2006-03-22 00:18:23 UTC (rev 836) +++ trunk/ebase/lib/Everything/HTML/FormObject/PermissionMenu.pm 2006-03-22 00:32:27 UTC (rev 837) @@ -87,7 +87,7 @@ $this->SUPER::genObject( $query, $bindNode, "${field}:$perm", $name ) . "\n"; - if ( $default eq 'AUTO' && UNIVERSAL::isa( $bindNode, 'Everything::Node' ) ) + if ( $default eq 'AUTO' && eval { $bindNode->isa( 'Everything::Node' ) } ) { my $perms = $bindNode->{$field}; $default = substr( $perms, $masks{$perm}, 1 ); Modified: trunk/ebase/lib/Everything/Mail.pm =================================================================== --- trunk/ebase/lib/Everything/Mail.pm 2006-03-22 00:18:23 UTC (rev 836) +++ trunk/ebase/lib/Everything/Mail.pm 2006-03-22 00:32:27 UTC (rev 837) @@ -10,6 +10,7 @@ use Mail::Sender; use Mail::Address; +use Scalar::Util 'reftype'; use Exporter (); use vars qw( $VERSION @ISA @EXPORT ); @@ -28,7 +29,7 @@ $node = getNode($node); return unless $node; - my @addresses = ( UNIVERSAL::isa( $addr, 'ARRAY' ) ? @$addr : $addr ); + my @addresses = ( reftype( $addr ) || '' ) eq 'ARRAY' ? @$addr : $addr; my $body = $node->{doctext} || ''; Everything::logErrors('Sending email with empty body') @@ -88,7 +89,7 @@ # Nothing to do here! return Everything::logErrors('No input files for mail2node!') unless $files; - $files = [$files] unless UNIVERSAL::isa( $files, 'ARRAY' ); + $files = [$files] unless ( reftype( $files ) || '' ) eq 'ARRAY'; my ( $from, $to, $subject, $body ); foreach my $file (@$files) Modified: trunk/ebase/lib/Everything/Node/node.pm =================================================================== --- trunk/ebase/lib/Everything/Node/node.pm 2006-03-22 00:18:23 UTC (rev 836) +++ trunk/ebase/lib/Everything/Node/node.pm 2006-03-22 00:32:27 UTC (rev 837) @@ -12,10 +12,13 @@ use warnings; use DBI; + use Everything; use Everything::NodeBase; use Everything::XML; +use Scalar::Util 'reftype'; + sub construct { 1 } sub destruct { 1 } @@ -43,7 +46,7 @@ my $node_id = $this->{node_id}; my ( $user_id, %tableData ); - $user_id = $USER->getId() if UNIVERSAL::isa( $USER, 'Everything::Node' ); + $user_id = $USER->getId() if eval { $USER->isa( 'Everything::Node' ) }; $user_id ||= $USER; @@ -431,7 +434,7 @@ { my ( $this, $NODE, $USER ) = @_; - return unless $NODE and UNIVERSAL::isa( $NODE, 'HASH' ); + return unless $NODE and ( reftype( $NODE ) || '' ) eq 'HASH'; my %unique = map { $_ => 1 } qw( title createtime type_nodetype type ); Modified: trunk/ebase/lib/Everything/Node/nodeball.pm =================================================================== --- trunk/ebase/lib/Everything/Node/nodeball.pm 2006-03-22 00:18:23 UTC (rev 836) +++ trunk/ebase/lib/Everything/Node/nodeball.pm 2006-03-22 00:32:27 UTC (rev 837) @@ -48,7 +48,7 @@ my $title = 'ROOT'; $title = $user->{title} - if $user && UNIVERSAL::isa( $user, 'Everything::Node' ); + if $user && $user->isa( 'Everything::Node' ); $VARS = { author => $title, Modified: trunk/ebase/lib/Everything/Node/nodegroup.pm =================================================================== --- trunk/ebase/lib/Everything/Node/nodegroup.pm 2006-03-22 00:18:23 UTC (rev 836) +++ trunk/ebase/lib/Everything/Node/nodegroup.pm 2006-03-22 00:32:27 UTC (rev 837) @@ -15,7 +15,9 @@ use Everything; use Everything::XML; + use XML::DOM; +use Scalar::Util 'reftype'; sub construct { @@ -501,7 +503,7 @@ return 0 unless $USER and $insert and $this->hasAccess( $USER, 'w' ); # converts to a list reference w/ 1 element if we get a scalar - my $insertref = [$insert] unless UNIVERSAL::isa( $insert, 'ARRAY' ); + my $insertref = [$insert] unless ( reftype( $insert ) || '' eq 'ARRAY' ); $insertref = $this->restrict_type($insertref); @@ -606,7 +608,7 @@ return 0 unless $this->hasAccess( $USER, 'w' ); - $REPLACE = [$REPLACE] unless UNIVERSAL::isa( $REPLACE, 'ARRAY' ); + $REPLACE = [$REPLACE] unless ( reftype( $REPLACE ) || '' ) eq 'ARRAY'; $REPLACE = $this->restrict_type($REPLACE); Modified: trunk/ebase/lib/Everything/NodeBase.pm =================================================================== --- trunk/ebase/lib/Everything/NodeBase.pm 2006-03-22 00:18:23 UTC (rev 836) +++ trunk/ebase/lib/Everything/NodeBase.pm 2006-03-22 00:32:27 UTC (rev 837) @@ -70,7 +70,7 @@ my $cacheSize = 300; # Get the settings from the system - if ( defined $CACHE && UNIVERSAL::isa( $CACHE, 'Everything::Node' ) ) + if ( defined $CACHE && $CACHE->isa( 'Everything::Node' ) ) { my $vars = $CACHE->getVars(); $cacheSize = $vars->{maxSize} if exists $vars->{maxSize}; @@ -150,8 +150,8 @@ my $cmpval = sub { my ( $val1, $val2 ) = @_; - $val1 = $val1->{node_id} if UNIVERSAL::isa( $val1, 'Everything::Node' ); - $val2 = $val2->{node_id} if UNIVERSAL::isa( $val2, 'Everything::Node' ); + $val1 = $val1->{node_id} if eval { $val1->isa( 'Everything::Node' ) }; + $val2 = $val2->{node_id} if eval { $val2->isa( 'Everything::Node' ) }; $val1 eq $val2; }; Modified: trunk/ebase/lib/Everything.pm =================================================================== --- trunk/ebase/lib/Everything.pm 2006-03-22 00:18:23 UTC (rev 836) +++ trunk/ebase/lib/Everything.pm 2006-03-22 00:32:27 UTC (rev 837) @@ -14,7 +14,9 @@ ############################################################################# use strict; + use DBI; +use Scalar::Util 'reftype'; use vars qw($DB $VERSION); @@ -335,7 +337,7 @@ my ( $db, $options ) = @_; $options = {} unless defined $options - and UNIVERSAL::isa( $options, 'HASH' ); + and (reftype( $options ) || '' ) eq 'HASH'; # Make sure that we clear the warnings/errors for this go around. clearFrontside(); Modified: trunk/ebase/t/HTML/Datetime.t =================================================================== --- trunk/ebase/t/HTML/Datetime.t 2006-03-22 00:18:23 UTC (rev 836) +++ trunk/ebase/t/HTML/Datetime.t 2006-03-22 00:32:27 UTC (rev 837) @@ -314,7 +314,7 @@ { my ($subname) = $AUTOLOAD =~ /([^:]+)$/; - if ( my $sub = UNIVERSAL::can( $package, $subname ) ) + if ( my $sub = $package->can( $subname ) ) { $sub->(@_); } Modified: trunk/ebase/t/HTML/FormObject/AuthorMenu.t =================================================================== --- trunk/ebase/t/HTML/FormObject/AuthorMenu.t 2006-03-22 00:18:23 UTC (rev 836) +++ trunk/ebase/t/HTML/FormObject/AuthorMenu.t 2006-03-22 00:32:27 UTC (rev 837) @@ -181,7 +181,7 @@ sub AUTOLOAD { my ($subname) = $AUTOLOAD =~ /([^:]+)$/; - if ( my $sub = UNIVERSAL::can( $package, $subname ) ) + if ( my $sub = $package->can( $subname ) ) { $sub->(@_); } Modified: trunk/ebase/t/HTML/FormObject/ListMenu.t =================================================================== --- trunk/ebase/t/HTML/FormObject/ListMenu.t 2006-03-22 00:18:23 UTC (rev 836) +++ trunk/ebase/t/HTML/FormObject/ListMenu.t 2006-03-22 00:32:27 UTC (rev 837) @@ -151,7 +151,7 @@ { my ($subname) = $AUTOLOAD =~ /([^:]+)$/; - if ( my $sub = UNIVERSAL::can( $package, $subname ) ) + if ( my $sub = $package->can( $subname ) ) { $sub->(@_); } Modified: trunk/ebase/t/HTML/FormObject/NodetypeMenu.t =================================================================== --- trunk/ebase/t/HTML/FormObject/NodetypeMenu.t 2006-03-22 00:18:23 UTC (rev 836) +++ trunk/ebase/t/HTML/FormObject/NodetypeMenu.t 2006-03-22 00:32:27 UTC (rev 837) @@ -265,7 +265,7 @@ { my ($subname) = $AUTOLOAD =~ /([^:]+)$/; - if ( my $sub = UNIVERSAL::can( $package, $subname ) ) + if ( my $sub = $package->can( $subname ) ) { $sub->(@_); } Modified: trunk/ebase/t/NodeBase.t =================================================================== --- trunk/ebase/t/NodeBase.t 2006-03-22 00:18:23 UTC (rev 836) +++ trunk/ebase/t/NodeBase.t 2006-03-22 00:32:27 UTC (rev 837) @@ -285,8 +285,7 @@ $result = getRef( $mock, $first, $second, $third, $u ); is( $first, 'first', 'getRef() should modify references in place' ); is( $second, 'second', '... for all passed in node_ids' ); -ok( UNIVERSAL::isa( $third, 'Everything::Node' ), - '... not mangling existing nodes' ); +ok( $third->isa( 'Everything::Node' ), '... not mangling existing nodes' ); is( $u, undef, '... skipping undefined values' ); is( $result, 'first', '... returning node of first element' ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |