Merged with master and am ready to merge back
[dbsrgits/DBM-Deep.git] / lib / DBM / Deep / Sector / DBI.pm
CommitLineData
d6ecf579 1package DBM::Deep::Sector::DBI;
2
3use 5.006_000;
4
5use strict;
6use warnings FATAL => 'all';
7
a4d36ff6 8use base qw( DBM::Deep::Sector );
9
10use DBM::Deep::Sector::DBI::Reference ();
11use DBM::Deep::Sector::DBI::Scalar ();
12
a4d36ff6 13sub free {
14 my $self = shift;
15
16 $self->engine->storage->delete_from(
17 $self->table, $self->offset,
18 );
19}
20
21sub reload {
22 my $self = shift;
23 $self->_init;
24}
25
26sub load {
27 my $self = shift;
28 my ($engine, $offset, $type) = @_;
29
30 if ( $type eq 'refs' ) {
31 return DBM::Deep::Sector::DBI::Reference->new({
32 engine => $engine,
33 offset => $offset,
34 });
35 }
36 elsif ( $type eq 'datas' ) {
350896ee 37 my $sector = DBM::Deep::Sector::DBI::Scalar->new({
a4d36ff6 38 engine => $engine,
39 offset => $offset,
40 });
350896ee 41
42 if ( $sector->{data_type} eq 'R' ) {
43 return $self->load(
cf4a1344 44 $engine, $sector->{value}, 'refs',
350896ee 45 );
46 }
47
48 return $sector;
a4d36ff6 49 }
50
51 DBM::Deep->_throw_error( "'$offset': Don't know what to do with type '$type'" );
52}
d6ecf579 53
541;
55__END__