Mercurial > pub > Impl
diff Lib/IMPL/Code/Loader.pm @ 165:76515373dac0
Added Class::Template,
Rewritten SQL::Schema
'use parent' directive instead of 'use base'
author | wizard |
---|---|
date | Sat, 23 Apr 2011 23:06:48 +0400 |
parents | |
children | 4d0e1962161c |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Lib/IMPL/Code/Loader.pm Sat Apr 23 23:06:48 2011 +0400 @@ -0,0 +1,34 @@ +package IMPL::Code::Loader; +use strict; +use warnings; + +my %packages; + +sub Provide { + my ($self,$package) = @_; + + my ($declaringPackage,$file) = caller(); + $packages{$package} = { declaringPackage => $declaringPackage, file => $file, evidence => 'provide' }; +} + +sub Require { + my ($self,$package) = @_; + + return 1 if $packages{$package}; + + if (my $file = $INC{$package}) { + $packages{$package} = { file => $file, evidence => 'inc' }; + return 1; + } + + undef $@; + + if ( eval "require $package; 1;" and not $packages{$package}) { + $packages{$package} = { file => $INC{$package}, evidence => 'inc' }; + }; + + die $@ if $@ and not $!; +} + +1; +