comparison Lib/IMPL/Web/View/Metadata/ObjectMeta.pm @ 370:cbf4febf0930

ObjectMeta, Tests, migrating to the new metadata model.
author sergey
date Tue, 10 Dec 2013 03:02:01 +0400
parents 7c784144d2f1
children d5c8b955bf8d
comparison
equal deleted inserted replaced
369:7c784144d2f1 370:cbf4febf0930
1 package IMPL::Web::View::Metadata::FormMeta; 1 package IMPL::Web::View::Metadata::ObjectMeta;
2 use strict; 2 use strict;
3 3
4 use IMPL::lang;
4 use IMPL::Const qw(:prop); 5 use IMPL::Const qw(:prop);
5 use IMPL::declare { 6 use IMPL::declare {
6 require => { 7 require => {
7 Exception => 'IMPL::Exception', 8 Exception => 'IMPL::Exception',
8 ArgException => '-IMPL::InvalidArgumentException', 9 ArgException => '-IMPL::InvalidArgumentException',
9 OpException => '-IMPL::InvalidOperationException', 10 OpException => '-IMPL::InvalidOperationException',
10 PropertyInfo => 'IMPL::Class::PropertyInfo', 11 PropertyInfo => 'IMPL::Class::PropertyInfo',
11 AbstractObject => '-IMPL::Object::Abstract' 12 AbstractObject => '-IMPL::Object::Abstract'
12 }, 13 },
13 base => [ 14 base => [
14 'IMPL::Web::View::Metadata::BaseMeta' => '@_' 15 'IMPL::Web::View::Metadata::BaseMeta' => sub {
16 my ($model,$type,$args) = @_;
17 $type ||= typeof($model);
18 return ($model,$type,$args);
19 }
15 ], 20 ],
16 props => [ 21 props => [
17 isMultiple => PROP_RO, 22 isMultiple => PROP_RO,
18 holdingType => PROP_RO 23 holdingType => PROP_RO
19 ] 24 ]
24 }; 29 };
25 30
26 sub CTOR { 31 sub CTOR {
27 my ($this,$model,$type,$args) = @_; 32 my ($this,$model,$type,$args) = @_;
28 33
29 $type ||= typeof($model); 34 $type = $this->modelType;
30 $args->{isMultiple} ||= $type eq 'ARRAY'; 35
36 $args->{isMultiple} ||= $type && $type eq 'ARRAY';
31 37
32 if ($args) { 38 if ($args) {
33 $this->$_($args->{$_}) foreach grep $args->{$_}, qw(isMultiple holdingType); 39 $this->$_($args->{$_}) foreach grep $args->{$_}, qw(isMultiple holdingType);
34 } 40 }
35 } 41 }
56 $pt = $pi->type; 62 $pt = $pi->type;
57 } 63 }
58 64
59 push @props, Meta->new($pv, $pt, \%args); 65 push @props, Meta->new($pv, $pt, \%args);
60 } 66 }
61 } elsif ( $modelType eq 'HASH' ) { 67 } elsif ( $modelType && $modelType eq 'HASH' ) {
62 while ( my ($k,$v) = each %{$this->model || {}} ) { 68 while ( my ($k,$v) = each %{$this->model || {}} ) {
63 push @props, Meta->new($v,undef,{name => $k}); 69 push @props, Meta->new($v,undef,{name => $k});
64 } 70 }
65 } 71 }
66 72