pass special config options to drivers
Brian Cassidy [Wed, 22 Aug 2007 20:07:53 +0000 (20:07 +0000)]
Changes
Makefile.PL
lib/Catalyst/Plugin/ConfigLoader.pm

diff --git a/Changes b/Changes
index 4a8437d..4a702cc 100644 (file)
--- a/Changes
+++ b/Changes
@@ -5,6 +5,8 @@ Revision history for Perl extension Catalyst::Plugin::ConfigLoader.
       (Jason Kohles)
     - allow users to specify their own macros in
       MyApp->config->{ substitutions } (Johnathan Rockway)
+    - pass special constructor arguments to Config::Any. Requires Config::Any
+      0.08 (Gareth Kirwan)
 
     [DEPRECATION NOTICE]
     - the "file" and "config_local_suffix" config keys are now to be explicitly
index 9998e72..5b2a60c 100644 (file)
@@ -5,7 +5,7 @@ all_from 'lib/Catalyst/Plugin/ConfigLoader.pm';
 
 requires 'Catalyst::Runtime';
 requires 'Data::Visitor' => '0.02';
-requires 'Config::Any'   => '0.04';
+requires 'Config::Any'   => '0.08';
 
 requires 'Test::More';
 
index 188bd1c..12b1731 100644 (file)
@@ -24,13 +24,14 @@ Catalyst::Plugin::ConfigLoader - Load config files of various types
     
     # by default myapp.* will be loaded
     # you can specify a file if you'd like
-    __PACKAGE__->config( file => 'config.yaml' );    
+    __PACKAGE__->config( 'Plugin::ConfigLoader' => { file => 'config.yaml' } );    
 
 =head1 DESCRIPTION
 
 This module will attempt to load find and load a configuration
 file of various types. Currently it supports YAML, JSON, XML,
-INI and Perl formats.
+INI and Perl formats. Special configuration for a particular driver format can
+be stored in C<MyApp-E<gt>config-E<gt>{ 'Plugin::ConfigLoader' }-E<gt>{ driver }>.
 
 To support the distinction between development and production environments,
 this module will also attemp to load a local config (e.g. myapp_local.yaml)
@@ -50,9 +51,10 @@ sub setup {
     my $c     = shift;
     my @files = $c->find_files;
     my $cfg   = Config::Any->load_files( {
-        files   => \@files, 
-        filter  => \&_fix_syntax,
-        use_ext => 1
+        files       => \@files, 
+        filter      => \&_fix_syntax,
+        use_ext     => 1,
+        driver_args => $c->config->{'Plugin::ConfigLoader'}->{driver} || {},
     } );
 
     # split the responses into normal and local cfg