Mercurial > pub > Impl
view Lib/IMPL/Web/View/Metadata/ObjectProvider.pm @ 362:715b9959b207
WebView: initial work on metadata providers
author | cin |
---|---|
date | Thu, 28 Nov 2013 20:00:20 +0400 |
parents | |
children |
line wrap: on
line source
package IMPL::Web::View::Metadata::ObjectProvider; use strict; use IMPL::lang; use IMPL::declare { require => { Exception => 'IMPL::Exception', ArgException => '-IMPL::InvalidArgumentException', Meta => 'IMPL::Web::View::Metadata', PropertyInfo => 'IMPL::Class::PropertyInfo' }, base => [ 'IMPL::Object' => undef ] }; sub GetMetadata { my ($this,$model) = @_; my $class = typeof($model) || $model; return Meta->new( type => $class, provider => $this ); } # returns array of metadata sub GetFields { my ($this,$class) = @_; my %seen; return map { my %meta = ( provider => $this ); $meta{type} = $_->type if $_->type; # TODO extend from metadata and external providers return Meta->new(%meta); } $class->GetMeta(PropertyInfo, sub { $seen{$_->name} ? 0 : ($seen{$_->name} = 1) } , 1); } 1;