Mercurial > pub > Impl
comparison 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 |
comparison
equal
deleted
inserted
replaced
164:eb3e9861a761 | 165:76515373dac0 |
---|---|
1 package IMPL::Code::Loader; | |
2 use strict; | |
3 use warnings; | |
4 | |
5 my %packages; | |
6 | |
7 sub Provide { | |
8 my ($self,$package) = @_; | |
9 | |
10 my ($declaringPackage,$file) = caller(); | |
11 $packages{$package} = { declaringPackage => $declaringPackage, file => $file, evidence => 'provide' }; | |
12 } | |
13 | |
14 sub Require { | |
15 my ($self,$package) = @_; | |
16 | |
17 return 1 if $packages{$package}; | |
18 | |
19 if (my $file = $INC{$package}) { | |
20 $packages{$package} = { file => $file, evidence => 'inc' }; | |
21 return 1; | |
22 } | |
23 | |
24 undef $@; | |
25 | |
26 if ( eval "require $package; 1;" and not $packages{$package}) { | |
27 $packages{$package} = { file => $INC{$package}, evidence => 'inc' }; | |
28 }; | |
29 | |
30 die $@ if $@ and not $!; | |
31 } | |
32 | |
33 1; | |
34 |