annotate Lib/IMPL/Code/Loader.pm @ 265:6b6d4b2275a1

improved documentation
author cin
date Thu, 10 Jan 2013 03:25:02 +0400
parents 6d8092d8ce1b
children 8d36073411b1
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
230
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
5 use IMPL::Const qw(:prop);
209
a8db61d0ed33 IMPL::Class::Meta refactoring
cin
parents: 194
diff changeset
6
a8db61d0ed33 IMPL::Class::Meta refactoring
cin
parents: 194
diff changeset
7 use IMPL::declare {
a8db61d0ed33 IMPL::Class::Meta refactoring
cin
parents: 194
diff changeset
8 require => {
a8db61d0ed33 IMPL::Class::Meta refactoring
cin
parents: 194
diff changeset
9 Exception => 'IMPL::Exception',
a8db61d0ed33 IMPL::Class::Meta refactoring
cin
parents: 194
diff changeset
10 ArgumentException => '-IMPL::InvalidArgumentException'
a8db61d0ed33 IMPL::Class::Meta refactoring
cin
parents: 194
diff changeset
11 },
a8db61d0ed33 IMPL::Class::Meta refactoring
cin
parents: 194
diff changeset
12 base => {
a8db61d0ed33 IMPL::Class::Meta refactoring
cin
parents: 194
diff changeset
13 'IMPL::Object' => undef,
a8db61d0ed33 IMPL::Class::Meta refactoring
cin
parents: 194
diff changeset
14 'IMPL::Object::Autofill' => '@_'
230
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
15 },
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
16 props => [
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
17 verifyNames => PROP_RO,
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
18 prefix => PROP_RO,
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
19 _pending => PROP_RW
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
20 ]
209
a8db61d0ed33 IMPL::Class::Meta refactoring
cin
parents: 194
diff changeset
21 };
165
76515373dac0 Added Class::Template,
wizard
parents:
diff changeset
22
209
a8db61d0ed33 IMPL::Class::Meta refactoring
cin
parents: 194
diff changeset
23 my $default;
a8db61d0ed33 IMPL::Class::Meta refactoring
cin
parents: 194
diff changeset
24 sub default {
a8db61d0ed33 IMPL::Class::Meta refactoring
cin
parents: 194
diff changeset
25 $default ||= new IMPL::Code::Loader;
165
76515373dac0 Added Class::Template,
wizard
parents:
diff changeset
26 }
76515373dac0 Added Class::Template,
wizard
parents:
diff changeset
27
209
a8db61d0ed33 IMPL::Class::Meta refactoring
cin
parents: 194
diff changeset
28 my $safe;
a8db61d0ed33 IMPL::Class::Meta refactoring
cin
parents: 194
diff changeset
29 sub safe {
a8db61d0ed33 IMPL::Class::Meta refactoring
cin
parents: 194
diff changeset
30 $safe ||= new IMPL::Code::Loader(verifyNames => 1);
a8db61d0ed33 IMPL::Class::Meta refactoring
cin
parents: 194
diff changeset
31 }
a8db61d0ed33 IMPL::Class::Meta refactoring
cin
parents: 194
diff changeset
32
230
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
33 sub CTOR {
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
34 my ($this) = @_;
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
35
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
36 $this->_pending({});
209
a8db61d0ed33 IMPL::Class::Meta refactoring
cin
parents: 194
diff changeset
37 }
a8db61d0ed33 IMPL::Class::Meta refactoring
cin
parents: 194
diff changeset
38
165
76515373dac0 Added Class::Template,
wizard
parents:
diff changeset
39 sub Require {
209
a8db61d0ed33 IMPL::Class::Meta refactoring
cin
parents: 194
diff changeset
40 my ($this,$package) = @_;
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 165
diff changeset
41
209
a8db61d0ed33 IMPL::Class::Meta refactoring
cin
parents: 194
diff changeset
42 if ($this->verifyNames) {
229
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents: 209
diff changeset
43 $package =~ m/^([a-zA-Z_0-9]+(?:::[a-zA-Z_0-9]+)*)$/
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents: 209
diff changeset
44 or die ArgumentException->new(package => 'Invalid package name') ;
209
a8db61d0ed33 IMPL::Class::Meta refactoring
cin
parents: 194
diff changeset
45 }
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 165
diff changeset
46
229
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents: 209
diff changeset
47 $package = $this->prefix . '::' . $package if $this->prefix;
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 165
diff changeset
48
209
a8db61d0ed33 IMPL::Class::Meta refactoring
cin
parents: 194
diff changeset
49 my $file = join('/', split(/::/,$package)) . ".pm";
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 165
diff changeset
50
209
a8db61d0ed33 IMPL::Class::Meta refactoring
cin
parents: 194
diff changeset
51 require $file;
230
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
52
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
53 return $package;
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
54 }
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
55
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
56 sub GetFullName {
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
57 my ($this,$package) = @_;
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
58
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
59 if ($this->verifyNames) {
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
60 $package =~ m/^([a-zA-Z_0-9]+(?:::[a-zA-Z_0-9]+)*)$/
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
61 or die ArgumentException->new(package => 'Invalid package name') ;
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
62 }
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
63
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 229
diff changeset
64 return $this->prefix . '::' . $package if $this->prefix;
165
76515373dac0 Added Class::Template,
wizard
parents:
diff changeset
65 }
76515373dac0 Added Class::Template,
wizard
parents:
diff changeset
66
76515373dac0 Added Class::Template,
wizard
parents:
diff changeset
67 1;
76515373dac0 Added Class::Template,
wizard
parents:
diff changeset
68