Mercurial > pub > Impl
comparison Lib/IMPL/Config.pm @ 194:4d0e1962161c
Replaced tabs with spaces
IMPL::Web::View - fixed document model, new features (control classes, document constructor parameters)
author | cin |
---|---|
date | Tue, 10 Apr 2012 20:08:29 +0400 |
parents | d1676be8afcc |
children | d63f9a92d6d4 |
comparison
equal
deleted
inserted
replaced
193:8e8401c0aea4 | 194:4d0e1962161c |
---|---|
80 my ($this,$ctx) = @_; | 80 my ($this,$ctx) = @_; |
81 | 81 |
82 my $val; | 82 my $val; |
83 | 83 |
84 $val = $this->rawGet($_) and $ctx->AddVar($_ => $val) foreach map $_->Name, $this->get_meta( | 84 $val = $this->rawGet($_) and $ctx->AddVar($_ => $val) foreach map $_->Name, $this->get_meta( |
85 'IMPL::Class::PropertyInfo', | 85 'IMPL::Class::PropertyInfo', |
86 sub { | 86 sub { |
87 $_->Access == IMPL::Class::Member::MOD_PUBLIC and | 87 $_->Access == IMPL::Class::Member::MOD_PUBLIC and |
88 $_->canGet; | 88 $_->canGet; |
89 }, | 89 }, |
90 1); | 90 1); |
91 } | 91 } |
92 | 92 |
93 sub spawn { | 93 sub spawn { |
94 my ($this,$file) = @_; | 94 my ($this,$file) = @_; |
95 unless ($file) { | 95 unless ($file) { |
96 ($file = ref $this || $this) =~ s/:+/./g; | 96 ($file = ref $this || $this) =~ s/:+/./g; |
97 $file .= ".xml"; | 97 $file .= ".xml"; |
98 } | 98 } |
99 return $this->LoadXMLFile( File::Spec->catfile($ConfigBase,$file) ); | 99 return $this->LoadXMLFile( File::Spec->catfile($ConfigBase,$file) ); |
100 } | 100 } |
101 | 101 |
102 sub get { | 102 sub get { |
103 my $this = shift; | 103 my $this = shift; |
104 | 104 |
105 if (@_ == 1) { | 105 if (@_ == 1) { |
106 my $obj = $this->SUPER::get(@_); | 106 my $obj = $this->SUPER::get(@_); |
107 return UNIVERSAL::isa($obj,'IMPL::Config::Activator') ? $obj->activate : $obj; | 107 return UNIVERSAL::isa($obj,'IMPL::Config::Activator') ? $obj->activate : $obj; |
108 } else { | 108 } else { |
109 my @objs = $this->SUPER::get(@_); | 109 my @objs = $this->SUPER::get(@_); |
110 return map UNIVERSAL::isa($_,'IMPL::Config::Activator') ? $_->activate : $_, @objs ; | 110 return map UNIVERSAL::isa($_,'IMPL::Config::Activator') ? $_->activate : $_, @objs ; |
111 } | 111 } |
112 } | 112 } |
113 | 113 |
114 sub rawGet { | 114 sub rawGet { |
115 my $this = shift; | 115 my $this = shift; |
116 return $this->SUPER::get(@_); | 116 return $this->SUPER::get(@_); |
117 } | 117 } |
118 | 118 |
119 sub Exists { | 119 sub Exists { |
120 $_[0]->SUPER::get($_[1]) ? 1 : 0; | 120 $_[0]->SUPER::get($_[1]) ? 1 : 0; |
121 } | 121 } |
122 | 122 |
123 1; | 123 1; |
124 __END__ | 124 __END__ |
125 | 125 |
148 | 148 |
149 sub CTOR { | 149 sub CTOR { |
150 my $this = shift; | 150 my $this = shift; |
151 | 151 |
152 $this->DataSource( | 152 $this->DataSource( |
153 new IMPL::Config::Activator( | 153 new IMPL::Config::Activator( |
154 factory => 'MyDataSource', | 154 factory => 'MyDataSource', |
155 parameters=>{ | 155 parameters=>{ |
156 host => 'localhost', | 156 host => 'localhost', |
157 user => 'dbuser' | 157 user => 'dbuser' |
158 } | 158 } |
159 ) | 159 ) |
160 ) unless $this->Exists('DataSource'); | 160 ) unless $this->Exists('DataSource'); |
161 } | 161 } |
162 | 162 |
163 # using application object | 163 # using application object |
164 | 164 |
171 Ниже приведен пример файла C<default.xml> содержащего настройки приложения | 171 Ниже приведен пример файла C<default.xml> содержащего настройки приложения |
172 | 172 |
173 =begin code xml | 173 =begin code xml |
174 | 174 |
175 <app type='MyApp'> | 175 <app type='MyApp'> |
176 <SimpleString>The application</SimpleString> | 176 <SimpleString>The application</SimpleString> |
177 <DataSource type='IMPL::Config::Activator'> | 177 <DataSource type='IMPL::Config::Activator'> |
178 <factory>MyDataSourceClass</factory> | 178 <factory>MyDataSourceClass</factory> |
179 <parameters type='HASH'> | 179 <parameters type='HASH'> |
180 <host>localhost</host> | 180 <host>localhost</host> |
181 <user>dbuser</user> | 181 <user>dbuser</user> |
182 </parameters> | 182 </parameters> |
183 </DataSource> | 183 </DataSource> |
184 </app> | 184 </app> |
185 | 185 |
186 =end code xml | 186 =end code xml |
187 | 187 |
188 =head1 DESCRIPTION | 188 =head1 DESCRIPTION |