comparison Lib/IMPL/Transform.pm @ 7:94d47b388442

Улучшены тесты Исправлены ошибки Улучшена документация Работа над схемой DOM
author Sergey
date Mon, 24 Aug 2009 01:05:34 +0400
parents 03e58a454b20
children d660fb38b7cc
comparison
equal deleted inserted replaced
6:e2cd73ccc5bd 7:94d47b388442
1 package IMPL::Transform; 1 package IMPL::Transform;
2 use base qw(IMPL::Object IMPL::Object::Autofill); 2 use base qw(IMPL::Object);
3 3
4 use IMPL::Class::Property; 4 use IMPL::Class::Property;
5 use IMPL::Class::Property::Direct; 5 use IMPL::Class::Property::Direct;
6 6
7 BEGIN { 7 BEGIN {
8 protected _direct property Templates => prop_all; 8 protected _direct property Templates => prop_all;
9 protected _direct property Default => prop_all; 9 protected _direct property Default => prop_all;
10 protected _direct property Plain => prop_all; 10 protected _direct property Plain => prop_all;
11 } 11 }
12 12
13 __PACKAGE__->PassThroughArgs; 13 sub CTOR {
14 my ($this,%args) = @_;
15
16 $this->{$Plain} = delete $args{-plain};
17 $this->{$Default} = delete $args{-default};
18
19 $this->{$Templates} = \%args;
20 }
14 21
15 sub Transform { 22 sub Transform {
16 my ($this,$object) = @_; 23 my ($this,$object) = @_;
17 24
18 if (not ref $object) { 25 if (not ref $object) {
54 return new NewClass({ Name => $object->name, Document => $this->Transform($object->Data) }) 61 return new NewClass({ Name => $object->name, Document => $this->Transform($object->Data) })
55 }, 62 },
56 DocClass => sub { 63 DocClass => sub {
57 my ($this,$object) = @_; 64 my ($this,$object) = @_;
58 return new DocPreview(Author => $object->Author, Text => $object->Data); 65 return new DocPreview(Author => $object->Author, Text => $object->Data);
66 },
67 -default => sub {
68 my ($this,$object) = @_;
69 return $object;
70 },
71 -plain => sub {
72 my ($this,$object) = @_;
73 return $object;
59 } 74 }
60 ); 75 );
76
77 my $result = $t->Transform($obj);
61 78
62 =head1 Summary 79 =head1 Summary
63 . 80 .
64 81
65 =cut 82 =cut