comparison Lib/IMPL/Web/RestContract.pm @ 198:2ffe6f661605

Implemented IMPL::Web::Handler::RestController fixes in IMPL::Serialization completed IMPL::Web::Application::RestResource added IMPL::Web::Handler::JSONView added IMPL::Web::RestContract
author cin
date Fri, 20 Apr 2012 16:06:36 +0400
parents
children e743a8481327
comparison
equal deleted inserted replaced
197:6b1dda998839 198:2ffe6f661605
1 package IMPL::Web::RestContract;
2 use strict;
3
4 use IMPL::lang qw(:declare :constants);
5 use IMPL::declare {
6 require => {
7 Exception => 'IMPL::Exception',
8 InvalidOpException => '-IMPL::InvalidOperationException',
9 ForbiddenException => 'IMPL::Web::ForbiddenException',
10 TRestResource => 'IMPL::Web::Application::RestResource',
11 },
12 base => {
13 'IMPL::Transform' => sub { my %args = @_; $args{resources} },
14 'IMPL::Object::Serializable' => undef
15 }
16 };
17
18 sub CTOR {
19 my ($this) = @_;
20
21 $this->templates->{-plain} = sub { die ForbiddenException->new(); };
22 $this->templates->{-default} = sub { die ForbiddenException->new(); };
23 $this->templates->{TRestResource} = sub { $_[0] };
24 }
25
26 sub ProcessTemplate {
27 my ($this,$t,$obj,@args) = @_;
28
29 if (ref $t eq 'HASH') {
30 my $factory = $t->{factory} || TRestResource;
31 return $factory->new(%$t, target => $obj);
32 } elsif (ref $t eq 'CODE') {
33 return $this->$t($obj,@args);
34 } else {
35 die InvalidOpException->new();
36 }
37 }
38
39
40
41 1;
42
43 __END__
44
45 =pod
46
47 =head1 NAME
48
49 C<IMPL::Web::RestContract> Описывает правила публикации ресурсов.
50
51 =head1 SYNOPSIS
52
53 =begin code
54
55 =end code
56
57 =cut