annotate Lib/IMPL/declare.pm @ 351:cfd7570c2af2

working on TTView: created TTView class for rendering models
author cin
date Tue, 08 Oct 2013 17:40:35 +0400
parents a8dbddf491dd
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
1 package IMPL::declare;
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
2 use strict;
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
3
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
4 use Scalar::Util qw(set_prototype);
209
a8db61d0ed33 IMPL::Class::Meta refactoring
cin
parents: 198
diff changeset
5 use Carp qw(carp);
228
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
6 use IMPL::Class::PropertyInfo();
230
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 228
diff changeset
7 use IMPL::Const qw(:access);
251
9f394b27dccf require can handle recursive module references
sergey
parents: 230
diff changeset
8 use IMPL::require();
9f394b27dccf require can handle recursive module references
sergey
parents: 230
diff changeset
9
9f394b27dccf require can handle recursive module references
sergey
parents: 230
diff changeset
10 BEGIN {
9f394b27dccf require can handle recursive module references
sergey
parents: 230
diff changeset
11 *_require = *IMPL::require::_require;
9f394b27dccf require can handle recursive module references
sergey
parents: 230
diff changeset
12 *_trace = *IMPL::require::_trace;
9f394b27dccf require can handle recursive module references
sergey
parents: 230
diff changeset
13 }
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
14
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
15 sub import {
228
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
16 my ( $self, $args ) = @_;
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
17
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
18 return unless $args;
228
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
19
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
20 die "A hash reference is required" unless ref $args eq 'HASH';
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
21
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
22 no strict 'refs';
280
c6d0f889ef87 +IMPL::declare now supports meta attributes
cin
parents: 279
diff changeset
23 no warnings 'once';
228
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
24
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
25 my $caller = caller;
228
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
26
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
27 my $aliases = $args->{require} || {};
251
9f394b27dccf require can handle recursive module references
sergey
parents: 230
diff changeset
28
252
34a3f8668b58 fixed IMPL::require IMPL::declare
sergey
parents: 251
diff changeset
29 $IMPL::require::PENDING{$caller} = 1;
251
9f394b27dccf require can handle recursive module references
sergey
parents: 230
diff changeset
30 _trace("declare $caller");
9f394b27dccf require can handle recursive module references
sergey
parents: 230
diff changeset
31 $IMPL::require::level++;
228
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
32
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
33 while ( my ( $alias, $class ) = each %$aliases ) {
251
9f394b27dccf require can handle recursive module references
sergey
parents: 230
diff changeset
34 _trace("$alias => $class");
9f394b27dccf require can handle recursive module references
sergey
parents: 230
diff changeset
35 $IMPL::require::level ++;
198
2ffe6f661605 Implemented IMPL::Web::Handler::RestController
cin
parents: 197
diff changeset
36 my $c = _require($class);
228
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
37
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
38 *{"${caller}::$alias"} = set_prototype(
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
39 sub {
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
40 $c;
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
41 },
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
42 ''
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
43 );
251
9f394b27dccf require can handle recursive module references
sergey
parents: 230
diff changeset
44 $IMPL::require::level --;
228
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
45 }
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
46
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
47 my $base = $args->{base} || {};
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
48
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
49 my %ctor;
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
50 my @isa;
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
51
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
52 if ( ref $base eq 'ARRAY' ) {
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
53 carp "Odd elements number in require"
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
54 unless scalar(@$base) % 2 == 0;
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
55 while ( my ( $class, $mapper ) = splice @$base, 0, 2 ) {
251
9f394b27dccf require can handle recursive module references
sergey
parents: 230
diff changeset
56 _trace("parent $class");
9f394b27dccf require can handle recursive module references
sergey
parents: 230
diff changeset
57 $IMPL::require::level ++;
228
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
58 $class = $aliases->{$class} || _require($class);
251
9f394b27dccf require can handle recursive module references
sergey
parents: 230
diff changeset
59 $IMPL::require::level --;
228
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
60
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
61 push @isa, $class;
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
62 $ctor{$class} = $mapper;
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
63 }
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
64 }
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
65 elsif ( ref $base eq 'HASH' ) {
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
66 while ( my ( $class, $mapper ) = each %$base ) {
251
9f394b27dccf require can handle recursive module references
sergey
parents: 230
diff changeset
67 _trace("parent $class");
9f394b27dccf require can handle recursive module references
sergey
parents: 230
diff changeset
68 $IMPL::require::level ++;
228
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
69 $class = $aliases->{$class} || _require($class);
251
9f394b27dccf require can handle recursive module references
sergey
parents: 230
diff changeset
70 $IMPL::require::level --;
228
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
71
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
72 push @isa, $class;
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
73 $ctor{$class} = $mapper;
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
74 }
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
75 }
230
6d8092d8ce1b *reworked IMPL::Security
sergey
parents: 228
diff changeset
76
279
sergey
parents: 278
diff changeset
77 %{"${caller}::CTOR"} = %ctor;
sergey
parents: 278
diff changeset
78 push @{"${caller}::ISA"}, @isa;
sergey
parents: 278
diff changeset
79
sergey
parents: 278
diff changeset
80 if(ref($args->{meta}) eq 'ARRAY') {
sergey
parents: 278
diff changeset
81 $caller->SetMeta($_) foreach @{$args->{meta}};
sergey
parents: 278
diff changeset
82 }
228
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
83
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
84 my $props = $args->{props} || [];
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
85
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
86 if ( $props eq 'HASH' ) {
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
87 $props = [%$props];
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
88 }
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
89
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
90 die "A hash or an array reference is required in the properties list"
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
91 unless ref $props eq 'ARRAY';
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
92
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
93 carp "Odd elements number in properties declaration of $caller"
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
94 unless scalar(@$props) % 2 == 0;
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
95
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
96 if (@$props) {
256
32aceba4ee6d corrected ViewHandlers to handle cookies and headers.
sergey
parents: 252
diff changeset
97 $self->_implementProps($props,$caller);
228
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
98 }
251
9f394b27dccf require can handle recursive module references
sergey
parents: 230
diff changeset
99
256
32aceba4ee6d corrected ViewHandlers to handle cookies and headers.
sergey
parents: 252
diff changeset
100 if ($args->{_implement}) {
281
a8dbddf491dd refactoring
cin
parents: 280
diff changeset
101 $self->_implementProps($caller->abstractProps,$caller);
a8dbddf491dd refactoring
cin
parents: 280
diff changeset
102 $caller->abstractProps([]);
256
32aceba4ee6d corrected ViewHandlers to handle cookies and headers.
sergey
parents: 252
diff changeset
103 }
32aceba4ee6d corrected ViewHandlers to handle cookies and headers.
sergey
parents: 252
diff changeset
104
251
9f394b27dccf require can handle recursive module references
sergey
parents: 230
diff changeset
105 $IMPL::require::level--;
252
34a3f8668b58 fixed IMPL::require IMPL::declare
sergey
parents: 251
diff changeset
106 delete $IMPL::require::PENDING{$caller};
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
107 }
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
108
256
32aceba4ee6d corrected ViewHandlers to handle cookies and headers.
sergey
parents: 252
diff changeset
109 sub _implementProps {
32aceba4ee6d corrected ViewHandlers to handle cookies and headers.
sergey
parents: 252
diff changeset
110 my ($self, $props, $caller) = @_;
32aceba4ee6d corrected ViewHandlers to handle cookies and headers.
sergey
parents: 252
diff changeset
111
32aceba4ee6d corrected ViewHandlers to handle cookies and headers.
sergey
parents: 252
diff changeset
112 for ( my $i = 0 ; $i < @$props - 1 ; $i = $i + 2 ) {
32aceba4ee6d corrected ViewHandlers to handle cookies and headers.
sergey
parents: 252
diff changeset
113 my ( $prop, $spec ) = @{$props}[ $i, $i + 1 ];
278
4ddb27ff4a0b core refactoring
cin
parents: 275
diff changeset
114
4ddb27ff4a0b core refactoring
cin
parents: 275
diff changeset
115 $caller->ClassPropertyImplementor->Implement(
4ddb27ff4a0b core refactoring
cin
parents: 275
diff changeset
116 $spec,
256
32aceba4ee6d corrected ViewHandlers to handle cookies and headers.
sergey
parents: 252
diff changeset
117 {
275
6253872024a4 *refactoring IMPL::Class
cin
parents: 256
diff changeset
118 name => $prop,
6253872024a4 *refactoring IMPL::Class
cin
parents: 256
diff changeset
119 class => $caller,
6253872024a4 *refactoring IMPL::Class
cin
parents: 256
diff changeset
120 access => $prop =~ /^_/
256
32aceba4ee6d corrected ViewHandlers to handle cookies and headers.
sergey
parents: 252
diff changeset
121 ? ACCESS_PRIVATE
32aceba4ee6d corrected ViewHandlers to handle cookies and headers.
sergey
parents: 252
diff changeset
122 : ACCESS_PUBLIC
32aceba4ee6d corrected ViewHandlers to handle cookies and headers.
sergey
parents: 252
diff changeset
123 }
32aceba4ee6d corrected ViewHandlers to handle cookies and headers.
sergey
parents: 252
diff changeset
124 );
32aceba4ee6d corrected ViewHandlers to handle cookies and headers.
sergey
parents: 252
diff changeset
125 }
32aceba4ee6d corrected ViewHandlers to handle cookies and headers.
sergey
parents: 252
diff changeset
126 }
32aceba4ee6d corrected ViewHandlers to handle cookies and headers.
sergey
parents: 252
diff changeset
127
197
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
128 1;
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
129
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
130 __END__
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
131
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
132 =pod
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
133
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
134 =head1 NAME
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
135
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
136 C<IMPL::declare> - описывает класс
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
137
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
138 =head1 SYNOPSIS
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
139
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
140 =begin code
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
141
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
142 package My::Bar;
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
143
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
144 use IMPL::declare {
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
145 require => {
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
146 TFoo => 'My::Foo',
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
147 TBox => 'My::Box'
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
148 },
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
149 base => {
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
150 TFoo => '@_',
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
151 'IMPL::Object' => undef,
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
152 }
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
153 }
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
154
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
155 sub CreateBox {
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
156 my ($this) = @_;
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
157 return TBox->new($this);
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
158 }
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
159
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
160 =end code
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
161
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
162 Специальная ситрока C<@_> означает передачу параметров конструктора текущего класса конструктору
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
163 базового класса без изменений.
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
164
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
165 =head1 DESCRIPTION
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
166
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
167 Описывает текущий пакет(модуль) как класс. В качестве параметра получает ссылку на хеш,
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
168 в которой храняться метаданные для объявления класса.
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
169
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
170 =head1 METADATA
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
171
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
172 =head2 C<require>
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
173
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
174 Содержит ссылку на хеш с синонимами модулей, которые будут доступны в текушем модуле,
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
175 аналогично использованию C<IMPL::require>. Однако, если модуль не требует загрузки при
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
176 помощи C<require> нужно использовать префикс C<'-'> в его имени
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
177
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
178 =begin code
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
179
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
180 {
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
181 require => {
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
182 TObject => 'IMPL::Object', # will be loaded with require
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
183 TFoo => '-My:App::Data::Foo' # will not use 'require' to load module
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
184 }
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
185 }
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
186
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
187 =end code
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
188
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
189 =head2 C<base>
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
190
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
191 Обисывает базове классы для текущего класса. Если данный параметр - ссылка массив, то
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
192 этот массив будет превращен в массив C<@ISA>. Если данный параметр - ссылка на хеш, то
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
193 его ключи опичавют список базовых классов, а значения - преобразование параметров для
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
194 вызова базовых конструкторов.
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
195
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
196 В качестве имен базовых классов могут быть как полные имена модулей, так и назначенные
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
197 ранее псевдонимы. Использование префикса C<'-'> перед B<полным именем модуля> означает,
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
198 что модуль не требуется загружать, в случае с псевдонимами, префикс C<'-'> уже был указан
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
199 при их объявлении.
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
200
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
201 =begin code
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
202
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
203 {
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
204 require => {
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
205 TFoo => '-My:App::Data::Foo' # will not use 'require' to load module
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
206 },
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
207 base => {
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
208 TFoo => '@_', # pass parameters unchanged
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
209 'My::Base::Class' => sub { name => $_[0], data => $_[1] }, # remap parameters
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
210 '-My::Extentions' => undef, # do not pass any parameters
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
211 }
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
212 }
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
213
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
214 =end code
6b1dda998839 Added IMPL::declare, IMPL::require, to simplify module definitions
sergey
parents:
diff changeset
215
228
431db7034a88 Для синхронизации
andrei <andrei@nap21.upri>
parents: 211
diff changeset
216 =cut