|
From: Chris W. <la...@us...> - 2001-10-23 12:19:32
|
Update of /cvsroot/openinteract/SPOPS
In directory usw-pr-cvs1:/tmp/cvs-serv7026
Modified Files:
SPOPS.pm
Log Message:
updated clone() to rely on the initialization provided by new()
Index: SPOPS.pm
===================================================================
RCS file: /cvsroot/openinteract/SPOPS/SPOPS.pm,v
retrieving revision 1.52
retrieving revision 1.53
diff -C2 -d -r1.52 -r1.53
*** SPOPS.pm 2001/10/22 15:21:44 1.52
--- SPOPS.pm 2001/10/23 12:19:29 1.53
***************
*** 15,19 ****
@SPOPS::ISA = qw( Exporter Storable );
@SPOPS::EXPORT_OK = qw( _w _wm DEBUG );
! $SPOPS::VERSION = '0.51';
$SPOPS::Revision = substr(q$Revision$, 10);
--- 15,19 ----
@SPOPS::ISA = qw( Exporter Storable );
@SPOPS::EXPORT_OK = qw( _w _wm DEBUG );
! $SPOPS::VERSION = '0.51a';
$SPOPS::Revision = substr(q$Revision$, 10);
***************
*** 174,188 ****
DEBUG() && _w( 1, "Cloning new object of class ($class) from old ",
"object of class (", ref $self, ")" );
! my $clone = $class->new;
my $id_field = $class->id_field;
! if ( $id_field ) {
! my $new_id = $p->{ $id_field } || $p->{id};
! $clone->{ $id_field } = $new_id if ( $new_id );
! }
while ( my ( $k, $v ) = each %{ $self } ) {
next if ( $id_field and $k eq $id_field );
! $clone->{ $k } = $p->{ $k } || $v;
}
! return $clone;
}
--- 174,187 ----
DEBUG() && _w( 1, "Cloning new object of class ($class) from old ",
"object of class (", ref $self, ")" );
! my %initial_data = ();
my $id_field = $class->id_field;
! $initial_data{ $id_field } = $p->{ $id_field } || $p->{id};
!
while ( my ( $k, $v ) = each %{ $self } ) {
next if ( $id_field and $k eq $id_field );
! $initial_data{ $k } = $p->{ $k } || $v;
}
!
! return $class->new({ %initial_data, skip_default_values => 1 });
}
|