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