From: Tomas Doran Date: Fri, 2 Oct 2009 07:37:28 +0000 (+0100) Subject: Merge commit 'upstream/topic/configfile_default_codref_call' X-Git-Tag: 0.23~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMooseX-Getopt.git;a=commitdiff_plain;h=f2dfa116d68debe3d78919269774ff700f90ea2f;hp=-c Merge commit 'upstream/topic/configfile_default_codref_call' * commit 'upstream/topic/configfile_default_codref_call': if configfile is a coderef call it and write some tests for it --- f2dfa116d68debe3d78919269774ff700f90ea2f diff --combined lib/MooseX/Getopt.pm index 90a9d77,d0dbb3f..08bf037 --- a/lib/MooseX/Getopt.pm +++ b/lib/MooseX/Getopt.pm @@@ -11,7 -11,7 +11,7 @@@ use Carp () use Getopt::Long (); # GLD uses it anyway, doesn't hurt use constant HAVE_GLD => not not eval { require Getopt::Long::Descriptive }; -our $VERSION = '0.21'; +our $VERSION = '0.22'; our $AUTHORITY = 'cpan:STEVAN'; has ARGV => (is => 'rw', isa => 'ArrayRef', metaclass => "NoGetopt"); @@@ -31,6 -31,11 +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);