annotate Lib/IMPL/Code/Loader.pm @ 201:0c018a247c8a

Reworked REST resource classes to be more transparent and intuitive
author sergey
date Tue, 24 Apr 2012 19:52:07 +0400
parents 4d0e1962161c
children a8db61d0ed33
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
165
76515373dac0 Added Class::Template,
wizard
parents:
diff changeset
1 package IMPL::Code::Loader;
76515373dac0 Added Class::Template,
wizard
parents:
diff changeset
2 use strict;
76515373dac0 Added Class::Template,
wizard
parents:
diff changeset
3 use warnings;
76515373dac0 Added Class::Template,
wizard
parents:
diff changeset
4
76515373dac0 Added Class::Template,
wizard
parents:
diff changeset
5 my %packages;
76515373dac0 Added Class::Template,
wizard
parents:
diff changeset
6
76515373dac0 Added Class::Template,
wizard
parents:
diff changeset
7 sub Provide {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 165
diff changeset
8 my ($self,$package) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 165
diff changeset
9
4d0e1962161c Replaced tabs with spaces
cin
parents: 165
diff changeset
10 my ($declaringPackage,$file) = caller();
4d0e1962161c Replaced tabs with spaces
cin
parents: 165
diff changeset
11 $packages{$package} = { declaringPackage => $declaringPackage, file => $file, evidence => 'provide' };
165
76515373dac0 Added Class::Template,
wizard
parents:
diff changeset
12 }
76515373dac0 Added Class::Template,
wizard
parents:
diff changeset
13
76515373dac0 Added Class::Template,
wizard
parents:
diff changeset
14 sub Require {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 165
diff changeset
15 my ($self,$package) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 165
diff changeset
16
4d0e1962161c Replaced tabs with spaces
cin
parents: 165
diff changeset
17 return 1 if $packages{$package};
4d0e1962161c Replaced tabs with spaces
cin
parents: 165
diff changeset
18
4d0e1962161c Replaced tabs with spaces
cin
parents: 165
diff changeset
19 if (my $file = $INC{$package}) {
4d0e1962161c Replaced tabs with spaces
cin
parents: 165
diff changeset
20 $packages{$package} = { file => $file, evidence => 'inc' };
4d0e1962161c Replaced tabs with spaces
cin
parents: 165
diff changeset
21 return 1;
4d0e1962161c Replaced tabs with spaces
cin
parents: 165
diff changeset
22 }
4d0e1962161c Replaced tabs with spaces
cin
parents: 165
diff changeset
23
4d0e1962161c Replaced tabs with spaces
cin
parents: 165
diff changeset
24 undef $@;
4d0e1962161c Replaced tabs with spaces
cin
parents: 165
diff changeset
25
4d0e1962161c Replaced tabs with spaces
cin
parents: 165
diff changeset
26 if ( eval "require $package; 1;" and not $packages{$package}) {
4d0e1962161c Replaced tabs with spaces
cin
parents: 165
diff changeset
27 $packages{$package} = { file => $INC{$package}, evidence => 'inc' };
4d0e1962161c Replaced tabs with spaces
cin
parents: 165
diff changeset
28 };
4d0e1962161c Replaced tabs with spaces
cin
parents: 165
diff changeset
29
4d0e1962161c Replaced tabs with spaces
cin
parents: 165
diff changeset
30 die $@ if $@ and not $!;
165
76515373dac0 Added Class::Template,
wizard
parents:
diff changeset
31 }
76515373dac0 Added Class::Template,
wizard
parents:
diff changeset
32
76515373dac0 Added Class::Template,
wizard
parents:
diff changeset
33 1;
76515373dac0 Added Class::Template,
wizard
parents:
diff changeset
34