1 package Catalyst::Plugin::ConfigLoader;
\r
7 use Module::Pluggable::Fast
\r
8 name => '_config_loaders',
\r
9 search => [ __PACKAGE__ ],
\r
12 our $VERSION = '0.01';
\r
16 Catalyst::Plugin::ConfigLoader - Load config files of various types
\r
22 use Catalyst( ConfigLoader );
\r
24 # by default myapp.* will be loaded
\r
25 # you can specify a file if you'd like
\r
26 __PACKAGE__->config( file = > 'config.yaml' );
\r
31 This mdoule will attempt to load find and load a configuration
\r
32 file of various types. Currently it supports YAML, JSON, XML,
\r
33 INI and Perl formats.
\r
39 This method is automatically called by Catalyst's setup routine. It will
\r
40 attempt to use each plugin and set the C<config()> section once a file has been
\r
41 successfully loaded.
\r
47 my $confpath = $c->config->{ file } || $c->path_to( Catalyst::Utils::appprefix( ref $c || $c ) );
\r
49 for my $loader ( $c->_config_loaders ) {
\r
50 my $config = $loader->load( $confpath );
\r
52 $c->config( $config );
\r
57 $c->NEXT::setup( @_ );
\r
64 =item * Brian Cassidy E<lt>bricas@cpan.orgE<gt>
\r
68 =head1 COPYRIGHT AND LICENSE
\r
70 Copyright 2006 by Brian Cassidy
\r
72 This library is free software; you can redistribute it and/or modify
\r
73 it under the same terms as Perl itself.
\r