Data::Storage - Base class for storages


Data-Storage documentation Contained in the Data-Storage distribution.

Index


Code Index:

NAME

Top

Data::Storage - Base class for storages

VERSION

Top

version 1.102720

METHODS

Top

connect

FIXME

disconnect

FIXME

id

FIXME

lazy_connect

FIXME

setup

FIXME

signature

FIXME

test_setup

FIXME

INSTALLATION

Top

See perlmodinstall for information and options on installing Perl modules.

BUGS AND LIMITATIONS

Top

No bugs have been reported.

Please report any bugs or feature requests through the web interface at http://rt.cpan.org/Public/Dist/Display.html?Name=Data-Storage.

AVAILABILITY

Top

The latest version of this module is available from the Comprehensive Perl Archive Network (CPAN). Visit http://www.perl.com/CPAN/ to find a CPAN site near you, or see http://search.cpan.org/dist/Data-Storage/.

The development version lives at http://github.com/hanekomu/Data-Storage and may be cloned from git://github.com/hanekomu/Data-Storage. Instead of sending patches, please fork this project using the standard git and github infrastructure.

AUTHORS

Top

COPYRIGHT AND LICENSE

Top


Data-Storage documentation Contained in the Data-Storage distribution.

use 5.008;
use strict;
use warnings;

package Data::Storage;
BEGIN {
  $Data::Storage::VERSION = '1.102720';
}
# ABSTRACT: Base class for storages
use Class::Null;
use parent qw(
  Class::Accessor::Complex
  Class::Accessor::Constructor
);
__PACKAGE__
    ->mk_constructor
    ->mk_boolean_accessors(qw(rollback_mode))
    ->mk_abstract_accessors(qw(create initialize_data))
    ->mk_scalar_accessors(qw(log));
use constant is_abstract => 1;
use constant DEFAULTS => (log => Class::Null->new,);

sub setup {
    my $self = shift;
    $self->log->debug('creating storage schema');
    $self->create;
    $self->log->debug('populating storage with initial data');
    $self->initialize_data;
}
sub test_setup { }

# convenience method to access an object's id
sub id {
    my $self   = shift;
    my $object = shift;
    if ($@) {
        my $id = shift;
        $object->id($self, $id);
    } else {
        $object->id($self);
    }
}

# The storage object's signature is needed by Class::Scaffold::Storable to
# associate an object's id with the storage. We can't just store an id in a
# get_set_std accessor, because the business object's storage might be a
# multiplexing storage, and the object would have a different id in each
# multiplexed storage.
sub signature {
    my $self = shift;
    ref $self;
}
sub connect    { }
sub disconnect { }

# Some storage classes won't make a difference between a normal connection and
# a lazy connection - for memory storages, there is no connection anyway. But
# see Data::Storage::DBI for a way to use lazy connections.
sub lazy_connect { }
1;


__END__