X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FConfig-Any.git;a=blobdiff_plain;f=lib%2FConfig%2FAny%2FBase.pm;h=3f05e0f4d8468c45554c428210cf4ab72299e153;hp=65fe15f50c16f0f20ec15fc1887cee1a4cf8308c;hb=20190ef76826de69f3b7d6c53aaabe791b08a13c;hpb=c793253e5f2ad3ca9d60e96e07a5d87fa344ec31 diff --git a/lib/Config/Any/Base.pm b/lib/Config/Any/Base.pm index 65fe15f..3f05e0f 100644 --- a/lib/Config/Any/Base.pm +++ b/lib/Config/Any/Base.pm @@ -18,7 +18,7 @@ format. =head2 is_supported( ) Allows us to determine if the file format can be loaded. The can be done via -one of two subclass methds: +one of two subclass methods: =over 4 @@ -38,15 +38,16 @@ Lack of specifying these subs will assume you require no extra modules to functi sub is_supported { my ( $class ) = shift; + local $@; if ( $class->can( 'requires_all_of' ) ) { - eval join( '', map { _require_line( $_ ) } $class->requires_all_of ); - return $@ ? 0 : 1; + return eval { + _require($_) for $class->requires_all_of; + 1; + } || 0; } if ( $class->can( 'requires_any_of' ) ) { - for ( $class->requires_any_of ) { - eval _require_line( $_ ); - return 1 unless $@; - } + eval { _require( $_ ); 1 } and return 1 + for $class->requires_any_of; return 0; } @@ -54,27 +55,28 @@ sub is_supported { return 1; } -sub _require_line { +sub _require { my ( $input ) = shift; my ( $module, $version ) = ( ref $input ? @$input : $input ); - return "require $module;" - . ( $version ? "${module}->VERSION('${version}');" : '' ); + (my $file = "$module.pm") =~ s{::}{/}g; + require $file; + $module->VERSION if $version; } =head1 AUTHOR -Brian Cassidy Ebricas@cpan.orgE +Brian Cassidy =head1 COPYRIGHT AND LICENSE Copyright 2008-2009 by Brian Cassidy This library is free software; you can redistribute it and/or modify -it under the same terms as Perl itself. +it under the same terms as Perl itself. =head1 SEE ALSO -=over 4 +=over 4 =item * L