package Oryx::DBM::Util; use File::Spec; use DBM::Deep; sub new { my $class = shift; return bless { }, $class; } sub table_exists { my ($self, $dbm, $table) = @_; return -e File::Spec->catfile($dbm->datapath, $table); } sub table_create { my ($self, $dbm, $table) = @_; my $filename = File::Spec->catfile($dbm->datapath, $table); $dbm->catalog->put( $table, { file => $filename, type => DBM::Deep::TYPE_ARRAY, autoflush => 1, locking => 1, }); } sub table_drop { my ($self, $dbm, $table) = @_; my $meta = $dbm->catalog->get( $table ); return unless $meta; # not defined for link tables unlink $meta->{file}; $dbm->catalog->delete( $table ); } 1; __END__ =head1 NAME Oryx::DBM::Util - Oryx DBM utilities =head1 DESCRIPTION The following methods are defined to manipulate a L database schema. =head1 METHODS =over =item B Returns a true value if the table named C<$table> exists within C<$dbm>. =item B Creates a table named C<$table> in C<$dbm>. =item B Drops the table named C<$table> in C<$dbm>. =back =head1 AUTHORS Richard Hundt Erichard NO SPAM AT protea-systems.comE Andrew Sterling Hanenkamp Ehanenkamp@cpan.orgE =head1 COPYRIGHT AND LICENSE Copyright (c) 2005 Richard Hundt. This library is free software and may be used under the same terms as Perl itself. =cut