sub DESTROY {
my ($self) = @_;
$self->save if $self->{changes};
}
sub FETCH {
my ($self, $key) = @_;
my $record = $self->{records}->{$key};
return undef unless defined $record;
# return pointer to a copy of the record
return \%{$record};
}
sub STORE {
my ($self, $key, $record) = @_;
croak "Pointer to hash expected"
unless ref($record) eq "HASH";
$record->{$self->{keyfield}} = $key;
$self->{records}->{$key} = \%{$record};
$self->{changes}++;
}
sub DELETE {
my ($self, $key) = @_;
delete $self->{records}->{$key};
$self->{changes}++;
}
|