Subject: | [PATCH] $obj->new fails |
The following fails in OpenFrame 3.03:
my $obj1 = OpenFrame::Object->new();
my $obj2 = $obj1->new();
The attached patch fixes this, and introduces the $obj->class() method (which I like, but you might not :-).
-Steve
diff -ruN OpenFrame-3.03.orig/lib/OpenFrame/Object.pm OpenFrame-3.03/lib/OpenFrame/Object.pm
--- OpenFrame-3.03.orig/lib/OpenFrame/Object.pm Wed Mar 5 10:46:04 2003
+++ OpenFrame-3.03/lib/OpenFrame/Object.pm Fri May 2 08:56:54 2003
@@ -5,10 +5,10 @@
use OpenFrame;
-our $VERSION="3.03";
+our $VERSION="3.031";
sub new {
- my $class = shift;
+ my $class = shift->class;
my $self = {};
bless $self, $class;
$self->init(@_);
@@ -25,9 +25,15 @@
my $pack = ref( $self );
my ($package, $filename, $line, $subroutine, $hasargs,
$wantarray, $evaltext, $is_require, $hints, $bitmask) = caller( 1 );
+ $subroutine =~ s/.*:://;
if ($OpenFrame::DEBUG{ ALL } || $OpenFrame::DEBUG{ $pack }) {
warnings::warn("[$pack\::$subroutine] $mesg");
}
+}
+
+sub class {
+ my $thing = shift;
+ return ref($thing) || $thing;
}
1;
diff -ruN OpenFrame-3.03.orig/t/00object.t OpenFrame-3.03/t/00object.t
--- OpenFrame-3.03.orig/t/00object.t Tue Aug 13 17:55:37 2002
+++ OpenFrame-3.03/t/00object.t Fri May 2 08:56:40 2003
@@ -3,7 +3,7 @@
use strict;
use warnings;
-use Test::Simple tests => 3;
+use Test::Simple tests => 4;
use OpenFrame::Object;
ok(1, "loaded");
@@ -15,5 +15,7 @@
};
ok($@, "error message thrown");
-
+my $new_obj;
+eval { $new_obj = $object->new; };
+ok($new_obj, 'new object from object');