Name
Class::Usul::TraitFor::ConnectInfo - Provides the DBIC connect info array ref
Synopsis
package YourClass;
use Moo;
use Class::Usul::Constants;
use Class::Usul::Types qw( NonEmptySimpleStr Object );
with 'Class::Usul::TraitFor::ConnectInfo';
has 'database' => is => 'ro', isa => NonEmptySimpleStr,
default => 'database_name';
has 'schema' => is => 'lazy', isa => Object, builder => sub {
my $self = shift; my $extra = $self->config->connect_params;
$self->schema_class->connect( @{ $self->get_connect_info }, $extra ) };
has 'schema_class' => is => 'ro', isa => NonEmptySimpleStr,
default => 'dbic_schema_class_name';
sub config { # A class method
return { ...config parameters... }
}
Description
Provides the DBIC connect info array ref
Configuration and Environment
The JSON data looks like this:
{
"credentials" : {
"schedule" : {
"driver" : "mysql",
"host" : "localhost",
"password" : "{Twofish}U2FsdGVkX1/xcBKZB1giOdQkIt8EFgfNDFGm/C+fZTs=",
"port" : "3306",
"user" : "username"
}
}
}
Subroutines/Methods
dump_config_data
$dumped_data = $self->dump_config_data( $app_config, $db, $cfg_data );
Call the dump method to write the configuration file back to disk
extract_creds_from
$creds = $self->extract_creds_from( $app_config, $db, $cfg_data );
Returns the credential info for the specified database and (optional) subspace. The subspace attribute of $app_config
is appended to the database name to create a unique cache key
get_connect_info
$db_info_arr = $self->get_connect_info( $app_config, $db );
Returns an array ref containing the information needed to make a connection to a database; DSN, user id, password, and options hash ref. The data is read from the configuration file in the config ctrldir
. Multiple sets of data can be stored in the same file, keyed by the $db
argument. The password is decrypted if required
load_config_data
$cfg_data = $self->load_config_data( $app_config, $db );
Returns a hash ref of configuration file data. The path to the file can be specified in $app_config->{ctlfile}
or it will default to the $db.$extension
file in the $app_config->{ctrldir}
directory. The $extension
is either $app_config->{extension}
or $self->config->{extension}
or the default extension given by the CONFIG_EXTN
constant
Diagnostics
None
Dependencies
Incompatibilities
There are no known incompatibilities in this module
Bugs and Limitations
There are no known bugs in this module. Please report problems to the address below. Patches are welcome
Acknowledgements
Larry Wall - For the Perl programming language
Author
Peter Flanigan, <Support at RoxSoft.co.uk>
License and Copyright
Copyright (c) 2014 Peter Flanigan. All rights reserved
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic
This program is distributed in the hope that it will be useful, but WITHOUT WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE