if configfile is a coderef call it and write some tests for it
[gitmo/MooseX-Getopt.git] / lib / MooseX / Getopt.pm
index 4550082..d0dbb3f 100644 (file)
@@ -31,6 +31,11 @@ sub new_with_options {
         if(!defined $configfile) {
             my $cfmeta = $class->meta->find_attribute_by_name('configfile');
             $configfile = $cfmeta->default if $cfmeta->has_default;
+            if (ref $configfile eq 'CODE') {
+                # not sure theres a lot you can do with the class and may break some assumptions
+                # warn?
+                $configfile = &$configfile($class);
+            }
             if (defined $configfile) {
                 $config_from_file = eval {
                     $class->get_config_from_file($configfile);