NAME
Rose::DBx::MoreConfig - Rose::DB base class with extra configuration options
SYNOPSIS
package My::Data::Source;
use parent 'Rose::DBx::MoreConfig';
... define data sources ...
__PACKAGE__->auto_load_fixups;
...
DESCRIPTION
This package provides a base class for modules defining Rose::DB data sources. It extends Rose::DB to allow more flexibility in placement of the YAML configuration file, in order to better accommodate packaged distributions, shared repositories, and the like.
METHOD
- auto_load_fixups
-
Because it's common to break up data sources for different and possibly overlapping projects into several classes, it's difficult to store credentials for each datasource using Rose::DB's default YAML configuration scheme. It's built around the idea of a single rc file, but complains if that file includes fixups for data sources not known when the current class calls
auto_load_fixups
. So we override the Rose::DB default behavior in two ways:Warnings for data found in the rc file that apply to a data source we haven't (yet) seen are suppressed. This allows you to use a global rc file to supply credentials for several different classes.
Several different possibilities are checked, in order, for rc files:
/etc/rosedbrc
A .rosedbrc file in the same directory as Rose/DB.pm
A .rosedbrc file in your home directory
A .rosedbrc file in the same directory as the Perl module for the calling class. (This assumes that the class is defined in a .pm file with the same name as the class, as is typical.)
$ENV{ROSEDBRC}
If more than one of these files are present, they are evaluated in the order shown, so you can override values from "systemwide" files with "class-local" files.
Implementation note
One of the goals of the "local .rosedbrc" option provided here is to facilitate the distribution of Rose::DB-derived classes for a particular set of databases as packages or in an application's local library tree. However, for the same reasons that you want the content in your .rosedbrc separate from the rest of your module, you will likely not want to store a .rosedbrc with user credentials in a SCM repository that is visible by others. Depending on your SCM system, you may be able to exclude this file via an "ignore me" configuration directive (e.g. a .gitignore file or svn:ignore
property). Othewise, you will need to keep these files outside the development tree and include them when you build or deploy your distribution.
EXPORT
None.
DIAGNOSTICS
Any message that can be returned by an included package. Warnings generated by Rose::DB about unrecognized data sources encountered in a configuration file are suppressed.
BUGS AND CAVEATS
Are there, for certain, but have yet to be cataloged. Please don't hesitate to report any you find, using either CPAN or GitHub.
SEE ALSO
VERSION
version 1.01
REVISION
$Revision$ $Date$
AUTHOR
Charles Bailey <cbail@cpan.org>
COPYRIGHT AND LICENSE
Copyright (C) 2015 by Charles Bailey
This software may be used under the terms of the Artistic License or the GNU General Public License, as the user prefers.
ACKNOWLEDGMENT
The code incorporated into this package was originally written with United States federal funding as part of research work done by the author at the Children's Hospital of Philadelphia.