Class::Usul::TraitFor::ConnectInfo - Provides the DBIC connect info array ref
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... } }
Provides the DBIC connect information array reference
The JSON data looks like this:
{ "credentials" : { "schedule" : { "driver" : "mysql", "host" : "localhost", "password" : "{Twofish}U2FsdGVkX1/xcBKZB1giOdQkIt8EFgfNDFGm/C+fZTs=", "port" : "3306", "user" : "username" } } }
where in this example schedule is the database name
schedule
$dumped_data = $self->dump_config_data( $app_config, $db, $cfg_data );
Call the dump method to write the configuration file back to disk
$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
$app_config
$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
ctrldir
$db
$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 connect-info.$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
$app_config->{ctlfile}
$app_config->{ctrldir}
$extension
$app_config->{extension}
$self->config->{extension}
CONFIG_EXTN
None
There are no known incompatibilities in this module
There are no known bugs in this module. Please report problems to the address below. Patches are welcome
Larry Wall - For the Perl programming language
Peter Flanigan, <pjfl@cpan.org>
<pjfl@cpan.org>
Copyright (c) 2016 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
To install Class::Usul, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Class::Usul
CPAN shell
perl -MCPAN -e shell install Class::Usul
For more information on module installation, please visit the detailed CPAN module installation guide.