| 1 | package Data::Storage; |
|---|
| 2 | |
|---|
| 3 | # $Id: Storage.pm 13653 2007-10-22 09:11:20Z gr $ |
|---|
| 4 | |
|---|
| 5 | use strict; |
|---|
| 6 | use warnings; |
|---|
| 7 | use Class::Null; |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | our $VERSION = '0.03'; |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | use 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 | |
|---|
| 23 | use constant is_abstract => 1; |
|---|
| 24 | |
|---|
| 25 | |
|---|
| 26 | use constant DEFAULTS => ( |
|---|
| 27 | log => Class::Null->new, |
|---|
| 28 | ); |
|---|
| 29 | |
|---|
| 30 | |
|---|
| 31 | sub 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 | |
|---|
| 40 | sub test_setup {} |
|---|
| 41 | |
|---|
| 42 | |
|---|
| 43 | # convenience method to access an object's id |
|---|
| 44 | |
|---|
| 45 | sub 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 | |
|---|
| 63 | sub signature { |
|---|
| 64 | my $self = shift; |
|---|
| 65 | ref $self; |
|---|
| 66 | } |
|---|
| 67 | |
|---|
| 68 | |
|---|
| 69 | sub connect {} |
|---|
| 70 | sub 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 | |
|---|
| 76 | sub lazy_connect {} |
|---|
| 77 | |
|---|
| 78 | |
|---|
| 79 | 1; |
|---|
| 80 | |
|---|
| 81 | |
|---|
| 82 | __END__ |
|---|
| 83 | |
|---|
| 84 | =head1 NAME |
|---|
| 85 | |
|---|
| 86 | Data::Storage - generic abstract storage mechanism |
|---|
| 87 | |
|---|
| 88 | =head1 SYNOPSIS |
|---|
| 89 | |
|---|
| 90 | None yet (see below). |
|---|
| 91 | |
|---|
| 92 | =head1 DESCRIPTION |
|---|
| 93 | |
|---|
| 94 | None yet. This is an early release; fully functional, but undocumented. The |
|---|
| 95 | next release will have more documentation. |
|---|
| 96 | |
|---|
| 97 | =head1 TAGS |
|---|
| 98 | |
|---|
| 99 | If you talk about this module in blogs, on del.icio.us or anywhere else, |
|---|
| 100 | please use the C<datastorage> tag. |
|---|
| 101 | |
|---|
| 102 | =head1 BUGS AND LIMITATIONS |
|---|
| 103 | |
|---|
| 104 | No bugs have been reported. |
|---|
| 105 | |
|---|
| 106 | Please report any bugs or feature requests to |
|---|
| 107 | C<bug-data-storage@rt.cpan.org>, or through the web interface at |
|---|
| 108 | L<http://rt.cpan.org>. |
|---|
| 109 | |
|---|
| 110 | =head1 INSTALLATION |
|---|
| 111 | |
|---|
| 112 | See perlmodinstall for information and options on installing Perl modules. |
|---|
| 113 | |
|---|
| 114 | =head1 AVAILABILITY |
|---|
| 115 | |
|---|
| 116 | The latest version of this module is available from the Comprehensive Perl |
|---|
| 117 | Archive Network (CPAN). Visit <http://www.perl.com/CPAN/> to find a CPAN |
|---|
| 118 | site near you. Or see <http://www.perl.com/CPAN/authors/id/M/MA/MARCEL/>. |
|---|
| 119 | |
|---|
| 120 | =head1 AUTHORS |
|---|
| 121 | |
|---|
| 122 | Marcel GrE<uuml>nauer, C<< <marcel@cpan.org> >> |
|---|
| 123 | |
|---|
| 124 | =head1 COPYRIGHT AND LICENSE |
|---|
| 125 | |
|---|
| 126 | Copyright 2007 by Marcel GrE<uuml>nauer |
|---|
| 127 | |
|---|
| 128 | This library is free software; you can redistribute it and/or modify |
|---|
| 129 | it under the same terms as Perl itself. |
|---|
| 130 | |
|---|
| 131 | =cut |
|---|
| 132 | |
|---|