##
# If value is blessed, preserve class name
##
- my $value_class = Scalar::Util::blessed($value);
- if ($self->root->{autobless} && defined $value_class && $value_class ne 'DBM::Deep' ) {
- ##
- # Blessed ref -- will restore later
- ##
- $self->fh->print( chr(1) );
- $self->fh->print( pack($DATA_LENGTH_PACK, length($value_class)) . $value_class );
- $content_length += 1;
- $content_length += $DATA_LENGTH_SIZE + length($value_class);
- }
-
+ if ( $self->root->{autobless} ) {
+ my $value_class = Scalar::Util::blessed($value);
+ if ( defined $value_class && $value_class ne 'DBM::Deep' ) {
+ ##
+ # Blessed ref -- will restore later
+ ##
+ $self->fh->print( chr(1) );
+ $self->fh->print( pack($DATA_LENGTH_PACK, length($value_class)) . $value_class );
+ $content_length += 1;
+ $content_length += $DATA_LENGTH_SIZE + length($value_class);
+ }
+ else {
+ $self->fh->print( chr(0) );
+ $content_length += 1;
+ }
+ }
+
##
# If this is a new content area, advance EOF counter
##
my $key = $self->first_key();
while ($key) {
my $value = $self->get($key);
+#XXX This doesn't work with autobless
if (!ref($value)) { $db_temp->{$key} = $value; }
else {
my $type = $value->type;
sub foo { 'foo' };
}
-use Test::More no_plan => 1;
+use Test::More tests => 24;
use_ok( 'DBM::Deep' );
my $db2 = DBM::Deep->new(
file => 't/test.db',
- autoflush => 1,
autobless => 1,
);
if ($db2->error()) {
is( $db2->{unblessed}{b}[1], 2 );
is( $db2->{unblessed}{b}[2], 3 );
+TODO: {
+ todo_skip "_copy_node() doesn't work with autobless", 1;
+ my $structure = $db2->export();
+ ok( 1 );
+}
+
my $db3 = DBM::Deep->new(
file => 't/test.db',
- autoflush => 1,
-# autobless => 0,
);
if ($db3->error()) {
die "ERROR: " . $db3->error();