CDB-TinyCDB-Wrapper

 view release on metacpan or  search on metacpan

lib/CDB/TinyCDB/Wrapper.pm  view on Meta::CPAN

package CDB::TinyCDB::Wrapper;

use warnings;
use strict;
use CDB::TinyCDB;

=head1 NAME

CDB::TinyCDB::Wrapper - A wrapper around CDB::TinyCDB to try and make
updating its files a little more transparent

=head1 VERSION

Version 0.03

=cut

our $VERSION = '0.03';

=head1 SYNOPSIS

Quick summary of what the module does.

Perhaps a little code snippet.

    use CDB::TinyCDB::Wrapper;
    my $db = CDB::TinyCDB::Wrapper->new();
    ...

=head1 SUBROUTINES/METHODS

=head2 new

=cut

sub new {
  my ($class, $filename) = @_;
  $class = ref($class) || $class;
  my $self = {filename => $filename,
              modified => {}};

  # If the file doesn't exist, dummy an empty file up. We can get away
  # with this because the BayesStore checks for file existence itself
  unless (-f $filename) {
    my $tmp;
    unless ($tmp = CDB::TinyCDB->create ($filename, "$filename.$$")) {
      #warn("Couldn't open $filename: $!");
      return 0;
    }
    $tmp->finish;
  }

  unless ($self->{cdb} = CDB::TinyCDB->load ($filename)) {
    #warn("Couldn't open $filename: $!");
    return 0;
  }

  bless ($self, $class);
  $self;
}

=head2 abandon

Indicates that whatever alterations were made should be thrown away
when the file is closed.

=cut

sub abandon {
  my ($self) = @_;



( run in 2.982 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )