Mercurial > pub > Impl
comparison Lib/IMPL/Web/View/Metadata/ObjectMeta.pm @ 371:d5c8b955bf8d
refactoring
| author | cin |
|---|---|
| date | Fri, 13 Dec 2013 16:49:47 +0400 |
| parents | cbf4febf0930 |
| children |
comparison
equal
deleted
inserted
replaced
| 370:cbf4febf0930 | 371:d5c8b955bf8d |
|---|---|
| 1 package IMPL::Web::View::Metadata::ObjectMeta; | 1 package IMPL::Web::View::Metadata::ObjectMeta; |
| 2 use strict; | 2 use strict; |
| 3 | 3 |
| 4 use IMPL::lang; | 4 use IMPL::lang; |
| 5 use IMPL::Const qw(:prop); | 5 use IMPL::Const qw(:prop :access); |
| 6 use IMPL::declare { | 6 use IMPL::declare { |
| 7 require => { | 7 require => { |
| 8 Exception => 'IMPL::Exception', | 8 Exception => 'IMPL::Exception', |
| 9 ArgException => '-IMPL::InvalidArgumentException', | 9 ArgException => '-IMPL::InvalidArgumentException', |
| 10 OpException => '-IMPL::InvalidOperationException', | 10 OpException => '-IMPL::InvalidOperationException', |
| 47 my @props; | 47 my @props; |
| 48 | 48 |
| 49 my $modelType = $this->modelType; | 49 my $modelType = $this->modelType; |
| 50 | 50 |
| 51 if ( isclass($modelType,AbstractObject) ) { | 51 if ( isclass($modelType,AbstractObject) ) { |
| 52 foreach my $pi ($this->modelType->GetMeta(PropertyInfo, sub { not($seen{$_}++) }, 1)) { | 52 foreach my $pi ( |
| 53 my $pv = $pi->getter->($this->model); | 53 $this->modelType->GetMeta( |
| 54 PropertyInfo, | |
| 55 sub { not($seen{$_}++) and $_->access == ACCESS_PUBLIC }, | |
| 56 1 | |
| 57 ) | |
| 58 ) { | |
| 59 my $pv = $this->model && $pi->getter->($this->model); | |
| 54 my $pt; | 60 my $pt; |
| 55 | 61 |
| 56 my %args = (name => $pi->name); | 62 my %args = (name => $pi->name); |
| 57 if ($pi->isList) { | 63 if ($pi->isList) { |
| 58 $pt = 'ARRAY'; | 64 $pt = 'ARRAY'; |
| 108 container => $this | 114 container => $this |
| 109 } | 115 } |
| 110 ); | 116 ); |
| 111 } | 117 } |
| 112 | 118 |
| 119 sub GetMetadataForModel { | |
| 120 my ($self,$model,$args) = @_; | |
| 121 | |
| 122 $args ||= {}; | |
| 123 | |
| 124 return $self->new( | |
| 125 $model, | |
| 126 delete $args->{modelType}, | |
| 127 $args | |
| 128 ) | |
| 129 } | |
| 130 | |
| 113 1; | 131 1; |
| 114 | 132 |
| 115 __END__ | 133 __END__ |
