Added recursion test, hoisted staleness() to Sector.pm, and refactored to write_bucke...
[dbsrgits/DBM-Deep.git] / lib / DBM / Deep / Sector.pm
1 package DBM::Deep::Sector;
2
3 use 5.006_000;
4
5 use strict;
6 use warnings FATAL => 'all';
7
8 use Scalar::Util ();
9
10 sub new {
11     my $self = bless $_[1], $_[0];
12     Scalar::Util::weaken( $self->{engine} );
13     $self->_init;
14     return $self;
15 }
16
17 sub _init {}
18 #sub clone { die "clone must be implemented in a child class" }
19 sub clone {
20     my $self = shift;
21     return ref($self)->new({
22         engine => $self->engine,
23         type   => $self->type,
24         data   => $self->data,
25     });
26 }
27
28
29 sub engine { $_[0]{engine} }
30 sub offset { $_[0]{offset} }
31 sub type   { $_[0]{type}   }
32 sub staleness { $_[0]{staleness} }
33
34 sub load { die "load must be implemented in a child class" }
35
36 1;
37 __END__