$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 ) {
+ bless $temp, $c;
+ }
+ }
+
return $temp;
}
$db->unlock();
You can pass C<lock()> an optional argument, which specifies which mode to use
-(exclusive or shared). Use one of these two constants: C<DBM::Deep-E<gt>LOCK_EX>
-or C<DBM::Deep-E<gt>LOCK_SH>. These are passed directly to C<flock()>, and are the
-same as the constants defined in Perl's C<Fcntl> module.
+(exclusive or shared). Use one of these two constants:
+C<DBM::Deep-E<gt>LOCK_EX> or C<DBM::Deep-E<gt>LOCK_SH>. These are passed
+directly to C<flock()>, and are the same as the constants defined in Perl's
+L<Fcntl/> module.
- $db->lock( DBM::Deep->LOCK_SH );
+ $db->lock( $db->LOCK_SH );
# something here
$db->unlock();
# DBM::Deep Test
##
use strict;
-use Test::More tests => 2;
+use Test::More tests => 6;
use Test::Deep;
use t::common qw( new_fh );
hash1 => {
subkey1 => "subvalue1",
subkey2 => "subvalue2",
- subkey3 => bless( {}, 'Foo' ),
+ subkey3 => bless( {
+ sub_obj => bless([
+ bless([], 'Foo'),
+ ], 'Foo'),
+ sub_obj2 => bless([], 'Foo'),
+ }, 'Foo' ),
},
);
-my $compare = do {
- my ($fh, $filename) = new_fh();
- my $db = DBM::Deep->new({
- file => $filename,
- autobless => 1,
- });
+my ($fh, $filename) = new_fh();
+my $db = DBM::Deep->new({
+ file => $filename,
+ autobless => 1,
+});
- ##
- # Create structure in DB
- ##
- $db->import( %struct );
+##
+# Create structure in DB
+##
+$db->import( %struct );
- ##
- # Export entire thing
- ##
- $db->export();
-};
+##
+# Export entire thing
+##
+my $compare = $db->export();
cmp_deeply(
$compare,
hash1 => {
subkey1 => "subvalue1",
subkey2 => "subvalue2",
- subkey3 => bless( {}, 'Foo' ),
+ subkey3 => bless( {
+ sub_obj => bless([
+ bless([], 'Foo'),
+ ], 'Foo'),
+ sub_obj2 => bless([], 'Foo'),
+ }, 'Foo' ),
},
},
"Everything matches",
);
+
+isa_ok( tied(%{$db->{hash1}{subkey3}})->export, 'Foo' );
+isa_ok( tied(@{$db->{hash1}{subkey3}{sub_obj}})->export, 'Foo' );
+isa_ok( tied(@{$db->{hash1}{subkey3}{sub_obj}[0]})->export, 'Foo' );
+isa_ok( tied(@{$db->{hash1}{subkey3}{sub_obj2}})->export, 'Foo' );