Mercurial > pub > Impl
annotate Lib/IMPL/Object.pm @ 239:23daf2fae33a
*security subsytem bugfixes
*HttpResponse: cookies which values are set to undefined will be deleted from browser
author | sergey |
---|---|
date | Tue, 16 Oct 2012 20:14:11 +0400 |
parents | 6d8092d8ce1b |
children | 8a5da17d7ef9 |
rev | line source |
---|---|
49 | 1 package IMPL::Object; |
2 use strict; | |
3 | |
165 | 4 use parent qw(IMPL::Object::Abstract); |
230 | 5 require IMPL::Class::Property::Direct; |
49 | 6 |
7 sub surrogate { | |
8 bless {}, ref $_[0] || $_[0]; | |
9 } | |
10 | |
180 | 11 __PACKAGE__->static_accessor( propertyInfoClass => 'IMPL::Class::DirectPropertyInfo' ); |
12 | |
49 | 13 sub new { |
14 my $class = shift; | |
15 my $self = bless {}, ref($class) || $class; | |
16 $self->callCTOR(@_); | |
17 | |
18 $self; | |
19 } | |
20 | |
21 sub _PropertyImplementor { | |
22 'IMPL::Class::Property::Direct' | |
23 } | |
24 | |
53 | 25 1; |
26 | |
27 __END__ | |
28 | |
49 | 29 =pod |
53 | 30 |
148
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
64
diff
changeset
|
31 =head1 SINOPSYS |
49 | 32 |
64 | 33 =begin code |
34 | |
49 | 35 package Foo; |
165 | 36 use parent qw(IMPL::Object); |
49 | 37 |
38 sub CTOR { | |
39 my ($this,$arg) = @_; | |
40 print "Foo: $arg\n"; | |
41 } | |
42 | |
43 package Bar; | |
165 | 44 use parent qw(IMPL::Object); |
49 | 45 |
46 sub CTOR { | |
47 my ($this,$arg) = @_; | |
48 print "Bar: $arg\n"; | |
49 } | |
50 | |
51 package Baz; | |
165 | 52 use parent qw(Foo Bar); |
49 | 53 |
54 our %CTOR = ( | |
55 Foo => sub { my %args = @_; $args{Mazzi}; }, | |
56 Bar => sub { my %args = @_; $args{Fugi}; } | |
57 ); | |
58 | |
59 package Composite; | |
165 | 60 use parent qw(Baz Foo Bar); |
49 | 61 |
62 our %CTOR = ( | |
63 Foo => undef, | |
64 Bar => undef | |
65 ); | |
66 | |
67 sub CTOR { | |
68 my ($this,%args) = @_; | |
69 | |
70 print "Composite: $args{Text}\n"; | |
71 } | |
72 | |
73 package main; | |
74 | |
75 my $obj = new Composite( | |
76 Text => 'Hello World!', | |
77 Mazzi => 'Mazzi', | |
78 Fugi => 'Fugi' | |
79 ); | |
80 | |
81 # will print | |
82 # | |
83 # Foo: Mazzi | |
84 # Bar: Fugi | |
85 # Bar: | |
86 # Composite: Hello World! | |
87 | |
64 | 88 =end code |
89 | |
53 | 90 =head1 Description |
91 | |
180 | 92 Базовый класс для объектов, основанных на хеше. |
49 | 93 |
53 | 94 =head1 Members |
49 | 95 |
53 | 96 =over |
49 | 97 |
98 =item operator C<new>(@args) | |
99 | |
180 | 100 Создает экземпляр объекта и вызывает конструктор с параметрами @args. |
49 | 101 |
102 =item operator C<surrogate>() | |
103 | |
180 | 104 Создает неинициализированный экземпляр объекта. |
49 | 105 |
106 =back | |
107 | |
53 | 108 =head1 Cavearts |
49 | 109 |
180 | 110 Нужно заметить, что директива C<use parent> работает не совсем прозрачно, если в нашем примере |
111 класс C<Composite> наследуется от C<Baz>, а затем C<Foo>, то наследование от | |
112 C<Foo> не произойдет поскольку он уже имеется в C<Baz>. Вот не задача:) | |
49 | 113 |
114 =cut |