Mercurial > pub > Impl
annotate Lib/IMPL/Web/View/ObjectFactory.pm @ 250:129e48bb5afb
DOM refactoring
ObjectToDOM methods are virtual
QueryToDOM uses inflators
Fixed transform for the complex values in the ObjectToDOM
QueryToDOM doesn't allow to use complex values (HASHes) as values for nodes (overpost problem)
author | sergey |
---|---|
date | Wed, 07 Nov 2012 04:17:53 +0400 |
parents | 7c517134c42f |
children |
rev | line source |
---|---|
240
abc7c26bf615
+Added ObjectFactory for templates with static members support
sergey
parents:
diff
changeset
|
1 package IMPL::Web::View::ObjectFactory; |
abc7c26bf615
+Added ObjectFactory for templates with static members support
sergey
parents:
diff
changeset
|
2 use strict; |
abc7c26bf615
+Added ObjectFactory for templates with static members support
sergey
parents:
diff
changeset
|
3 |
abc7c26bf615
+Added ObjectFactory for templates with static members support
sergey
parents:
diff
changeset
|
4 our $AUTOLOAD; |
abc7c26bf615
+Added ObjectFactory for templates with static members support
sergey
parents:
diff
changeset
|
5 |
abc7c26bf615
+Added ObjectFactory for templates with static members support
sergey
parents:
diff
changeset
|
6 use IMPL::declare { |
abc7c26bf615
+Added ObjectFactory for templates with static members support
sergey
parents:
diff
changeset
|
7 require => { |
abc7c26bf615
+Added ObjectFactory for templates with static members support
sergey
parents:
diff
changeset
|
8 Exception => 'IMPL::Exception', |
abc7c26bf615
+Added ObjectFactory for templates with static members support
sergey
parents:
diff
changeset
|
9 OpException => '-IMPL::InvalidOperationException' |
abc7c26bf615
+Added ObjectFactory for templates with static members support
sergey
parents:
diff
changeset
|
10 }, |
abc7c26bf615
+Added ObjectFactory for templates with static members support
sergey
parents:
diff
changeset
|
11 base =>[ |
abc7c26bf615
+Added ObjectFactory for templates with static members support
sergey
parents:
diff
changeset
|
12 'IMPL::Object::Factory' => '@_' |
abc7c26bf615
+Added ObjectFactory for templates with static members support
sergey
parents:
diff
changeset
|
13 ] |
abc7c26bf615
+Added ObjectFactory for templates with static members support
sergey
parents:
diff
changeset
|
14 }; |
abc7c26bf615
+Added ObjectFactory for templates with static members support
sergey
parents:
diff
changeset
|
15 |
245 | 16 use IMPL::Resources::Strings { |
17 MsgNoMethod => 'Method "%method%" isn\'t found in "%target%"' | |
18 }; | |
19 | |
240
abc7c26bf615
+Added ObjectFactory for templates with static members support
sergey
parents:
diff
changeset
|
20 sub AUTOLOAD { |
abc7c26bf615
+Added ObjectFactory for templates with static members support
sergey
parents:
diff
changeset
|
21 my $this = shift; |
abc7c26bf615
+Added ObjectFactory for templates with static members support
sergey
parents:
diff
changeset
|
22 my ($method) = ($AUTOLOAD =~ m/(\w+)$/); |
abc7c26bf615
+Added ObjectFactory for templates with static members support
sergey
parents:
diff
changeset
|
23 |
abc7c26bf615
+Added ObjectFactory for templates with static members support
sergey
parents:
diff
changeset
|
24 return if $method eq 'DESTROY'; |
abc7c26bf615
+Added ObjectFactory for templates with static members support
sergey
parents:
diff
changeset
|
25 my $target = $this->factory; |
abc7c26bf615
+Added ObjectFactory for templates with static members support
sergey
parents:
diff
changeset
|
26 if ( $target->can($method) ) { |
abc7c26bf615
+Added ObjectFactory for templates with static members support
sergey
parents:
diff
changeset
|
27 return $target->$method(@_); |
abc7c26bf615
+Added ObjectFactory for templates with static members support
sergey
parents:
diff
changeset
|
28 } else { |
245 | 29 die OpException->new( MsgNoMethod( method => $method, target => $target ) ); |
240
abc7c26bf615
+Added ObjectFactory for templates with static members support
sergey
parents:
diff
changeset
|
30 } |
abc7c26bf615
+Added ObjectFactory for templates with static members support
sergey
parents:
diff
changeset
|
31 } |
abc7c26bf615
+Added ObjectFactory for templates with static members support
sergey
parents:
diff
changeset
|
32 |
abc7c26bf615
+Added ObjectFactory for templates with static members support
sergey
parents:
diff
changeset
|
33 1; |