CGI-Application-Plugin-Config-Any
view release on metacpan or search on metacpan
lib/CGI/Application/Plugin/Config/Any.pm view on Meta::CPAN
my $value = _find_key( $self, $key, $config->{$subkey} );
return $value if $value;
}
return;
} # --- end sub _find_key ---
=pod
=head1 DEBUGGING
This module provides some internal debugging. Any debug messages go to
STDOUT, so beware of enabling debugging when running in a web
environment. (This will end up with "Internal Server Error"s in most
cases.)
There are two ways to enable the debug mode:
=over 4
=item In the module
Find line
$CGI::Application::Plugin::Config::Any::DEBUG = 0;
and set it to any "true" value. ("1", "TRUE", ... )
=item From outside the module
Add this line B<before> calling C<new>:
$CGI::Application::Plugin::Config::Any::DEBUG = 1;
=back
=cut
#-------------------------------------------------------------------
# METHOD: _debug
# + author: Bianka Martinovic
# + reviewed: 07-11-14 Bianka Martinovic
# + purpose: print out formatted _debug messages
#-------------------------------------------------------------------
sub _debug {
my $self = shift;
my $msg = shift;
my $dump;
if ( @_ ) {
if ( scalar ( @_ ) % 2 == 2 ) {
%{ $dump } = ( @_ );
}
else {
$dump = \@_;
}
}
my ( $package, $line, $sub ) = (caller())[0,2,3];
my ( $callerpackage, $callerline, $callersub )
= (caller(1))[0,2,3];
$sub ||= '-';
print "\n",
join( ' | ', $package, $line, $sub ),
"\n\tcaller: ",
join( ' | ', $callerpackage, $callerline, $callersub ),
"\n\t$msg",
"\n\n";
#if ( $dump ) {
# print $self->_dump( $dump );
#}
return;
} # --- end sub _debug ---
1;
__END__
=head1 AUTHOR
Bianka Martinovic, C<< <mab at cpan.org> >>
=head1 BUGS
B<This module is "work in progress" and subject to change without warning!>
=head2 Complex data structures
At the moment, there is no way to require a key buried deep in the config
data structure. Example for a more complex data structure (YAML syntax):
database_settings:
dsn: dbi:mysql:cm4web2:localhost
driver: mysql
host: localhost
port: 3306
additional_args:
ShowErrorStatement: 1
You can not require the key 'ShowErrorStatement' directly, 'cause it's a
subkey of 'additional_args', but the C<param()> method does not support
nested section names.
Anyway, if CAP::Config::Any isn't able to find a required key in the current
section, it walks through the complete config data structure to find it. So,
the following works with this example:
my $param = $self->config('ShowErrorStatement');
## this will return '1'
There is no way to suppress this at the moment, so beware of having similar
named keys in different sections of your configuration! You may not get what
you expected.
=head1 SUPPORT
( run in 0.976 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )