comparison Lib/IMPL/DOM/Transform/PostToDOM.pm @ 235:a4d9126edcbb

code cleaning
author sergey
date Fri, 12 Oct 2012 02:08:51 +0400
parents 4d0e1962161c
children
comparison
equal deleted inserted replaced
234:2530d1bb9638 235:a4d9126edcbb
1 package IMPL::DOM::Transform::PostToDOM; 1 package IMPL::DOM::Transform::PostToDOM;
2 use strict; 2 use strict;
3 use warnings; 3 use warnings;
4 4
5 use IMPL::DOM::Navigator::Builder; 5 use IMPL::Const qw(:prop);
6 use IMPL::Class::Property; 6 use IMPL::declare {
7 7 require => {
8 use parent qw(IMPL::Transform); 8 Builder => 'IMPL::DOM::Navigator::Builder'
9 9 },
10 BEGIN { 10 base => [
11 public property documentClass => prop_get | owner_set; 11 'IMPL::Transform' => sub {
12 public property documentSchema => prop_get | owner_set; 12 -plain => \&TransformPlain,
13 public property prefix => prop_get | owner_set; 13 HASH => \&TransformContainer,
14 private property _navi => prop_all; 14 CGI => \&TransformCGI,
15 public property Errors => prop_all | prop_list; 15 CGIWrapper => \&TransformCGI
16 private property _schema => prop_all; 16 }
17 } 17 ],
18 18 props => [
19 our %CTOR = ( 19 documentClass => PROP_RO,
20 'IMPL::Transform' => sub { 20 documentSchema => PROP_RO,
21 -plain => \&TransformPlain, 21 prefix => PROP_RO,
22 HASH => \&TransformContainer, 22 _navi => PROP_RW,
23 CGI => \&TransformCGI, 23 errors => PROP_RW | PROP_LIST,
24 CGIWrapper => \&TransformCGI 24 _schema => PROP_RW
25 } 25 ]
26 ); 26 };
27 27
28 sub CTOR { 28 sub CTOR {
29 my ($this,$docClass,$docSchema,$prefix) = @_; 29 my ($this,$docClass,$docSchema,$prefix) = @_;
30 $docClass ||= 'IMPL::DOM::Document'; 30 $docClass ||= 'IMPL::DOM::Document';
31 31
71 my ($this,$query) = @_; 71 my ($this,$query) = @_;
72 72
73 my $data={}; 73 my $data={};
74 74
75 my $prefix = $this->prefix; 75 my $prefix = $this->prefix;
76 my $delim = $this->delimiter;
76 77
77 foreach my $param (grep index($_,$prefix) >= 0 , $query->param()) { 78 foreach my $param (grep index($_,$prefix) >= 0 , $query->param()) {
78 length (my $value = $query->param($param)) or next; 79 length (my $value = $query->param($param)) or next;
79 80
80 my @parts = split /\//,$param; 81 my @parts = split /\//,$param;
93 $data = { document => $data }; 94 $data = { document => $data };
94 } 95 }
95 96
96 my $doc = $this->Transform($data); 97 my $doc = $this->Transform($data);
97 $doc->nodeProperty( query => $query ); 98 $doc->nodeProperty( query => $query );
98 $this->Errors->Append( $this->_navi->BuildErrors); 99 $this->errors->Append( $this->_navi->BuildErrors);
99 $this->Errors->Append( $this->_schema->Validate($doc)); 100 $this->errors->Append( $this->_schema->Validate($doc));
100 return $doc; 101 return $doc;
101 } 102 }
102 103
103 1; 104 1;
104 105