$self->_copy_node( $temp );
$self->unlock();
- # This will always work because $self, after _get_self() is a HASH
- if ( $self->{parent} ) {
- my $c = Scalar::Util::blessed(
- $self->{parent}->get($self->{parent_key})
- );
- if ( $c && !$c->isa( 'DBM::Deep' ) ) {
- bless $temp, $c;
- }
+ my $classname = $self->_engine->get_classname( $self->_storage->transaction_id, $self->_base_offset );
+ if ( defined $classname ) {
+ bless $temp, $classname;
}
return $temp;
#XXX This isn't the best solution. Better would be to use Data::Walker,
#XXX but that's a lot more thinking than I want to do right now.
eval {
- $self->begin_work;
+ #$self->begin_work;
$self->_import( _clone_data( $struct ) );
- $self->commit;
+ #$self->commit;
}; if ( $@ ) {
- $self->rollback;
+ #$self->rollback;
die $@;
}
return $value_sector->data;
}
+sub get_classname {
+ my $self = shift;
+ my ($trans_id, $base_offset) = @_;
+ print "get_classname( $trans_id, $base_offset )\n" if $DEBUG;
+
+ # This will be a Reference sector
+ my $sector = $self->_load_sector( $base_offset )
+ or die "How did read_value fail (no sector for '$base_offset')?!\n";
+
+ return $sector->get_classname;
+}
+
sub key_exists {
my $self = shift;
my ($trans_id, $base_offset, $key) = @_;
is( $db->{unblessed}{b}[2], 3 );
}
-SKIP: {
- skip "import() not ready yet", 2;
-my ($fh2, $filename2) = new_fh();
{
- my $db = DBM::Deep->new(
- file => $filename2,
- autobless => 1,
- );
- my $obj = bless {
- a => 1,
- b => [ 1 .. 3 ],
- }, 'Foo';
-
- $db->import( { blessed => $obj } );
-}
-
-{
- my $db = DBM::Deep->new(
- file => $filename2,
- autobless => 1,
- );
-
- my $blessed = $db->{blessed};
- isa_ok( $blessed, 'Foo' );
- is( $blessed->{a}, 1 );
-}
+ my ($fh2, $filename2) = new_fh();
+ {
+ my $db = DBM::Deep->new(
+ file => $filename2,
+ autobless => 1,
+ );
+ my $obj = bless {
+ a => 1,
+ b => [ 1 .. 3 ],
+ }, 'Foo';
+
+ $db->import( { blessed => $obj } );
+ }
+
+ {
+ my $db = DBM::Deep->new(
+ file => $filename2,
+ autobless => 1,
+ );
+
+ my $blessed = $db->{blessed};
+ isa_ok( $blessed, 'Foo' );
+ is( $blessed->{a}, 1 );
+ }
}
{