root/lang/perl/Data-Storage/tags/Data-Storage-0.03/lib/Data/Storage.pm @ 10093

Revision 10093, 2.6 kB (checked in by hanekomu, 5 years ago)

lang/perl/Data-Storage: initial import

Line 
1package Data::Storage;
2
3# $Id: Storage.pm 13653 2007-10-22 09:11:20Z gr $
4
5use strict;
6use warnings;
7use Class::Null;
8
9
10our $VERSION = '0.03';
11
12
13use base 'Class::Accessor::Complex';
14
15
16__PACKAGE__
17    ->mk_new
18    ->mk_boolean_accessors(qw(rollback_mode))
19    ->mk_abstract_accessors(qw(create initialize_data))
20    ->mk_scalar_accessors(qw(log));
21
22
23use constant is_abstract => 1;
24
25
26use constant DEFAULTS => (
27    log => Class::Null->new,
28);
29
30
31sub setup {
32    my $self = shift;
33    $self->log->debug('creating storage schema');
34    $self->create;
35    $self->log->debug('populating storage with initial data');
36    $self->initialize_data;
37}
38
39
40sub test_setup {}
41
42
43# convenience method to access an object's id
44
45sub id {
46    my $self   = shift;
47    my $object = shift;
48    if ($@) {
49        my $id = shift;
50        $object->id($self, $id);
51    } else {
52        $object->id($self);
53    }
54}
55
56
57# The storage object's signature is needed by Class::Scaffold::Storable to
58# associate an object's id with the storage. We can't just store an id in a
59# get_set_std accessor, because the business object's storage might be a
60# multiplexing storage, and the object would have a different id in each
61# multiplexed storage.
62
63sub signature {
64    my $self = shift;
65    ref $self;
66}
67
68
69sub connect {}
70sub disconnect {}
71
72# Some storage classes won't make a difference between a normal connection and
73# a lazy connection - for memory storages, there is no connection anyway. But
74# see Data::Storage::DBI for a way to use lazy connections.
75
76sub lazy_connect {}
77
78
791;
80
81
82__END__
83
84=head1 NAME
85
86Data::Storage - generic abstract storage mechanism
87
88=head1 SYNOPSIS
89
90None yet (see below).
91
92=head1 DESCRIPTION
93
94None yet. This is an early release; fully functional, but undocumented. The
95next release will have more documentation.
96
97=head1 TAGS
98
99If you talk about this module in blogs, on del.icio.us or anywhere else,
100please use the C<datastorage> tag.
101
102=head1 BUGS AND LIMITATIONS
103
104No bugs have been reported.
105
106Please report any bugs or feature requests to
107C<bug-data-storage@rt.cpan.org>, or through the web interface at
108L<http://rt.cpan.org>.
109
110=head1 INSTALLATION
111
112See perlmodinstall for information and options on installing Perl modules.
113
114=head1 AVAILABILITY
115
116The latest version of this module is available from the Comprehensive Perl
117Archive Network (CPAN). Visit <http://www.perl.com/CPAN/> to find a CPAN
118site near you. Or see <http://www.perl.com/CPAN/authors/id/M/MA/MARCEL/>.
119
120=head1 AUTHORS
121
122Marcel GrE<uuml>nauer, C<< <marcel@cpan.org> >>
123
124=head1 COPYRIGHT AND LICENSE
125
126Copyright 2007 by Marcel GrE<uuml>nauer
127
128This library is free software; you can redistribute it and/or modify
129it under the same terms as Perl itself.
130
131=cut
132
Note: See TracBrowser for help on using the browser.