comparison Lib/IMPL/Web/Application/RestCustomResource.pm @ 200:a9dbe534d236

sync
author sergey
date Tue, 24 Apr 2012 02:34:49 +0400
parents
children 0c018a247c8a
comparison
equal deleted inserted replaced
199:e743a8481327 200:a9dbe534d236
1 package IMPL::Web::Application::RestCustomResource;
2 use strict;
3
4 use IMPL::lang qw(:declare :constants);
5 use IMPL::declare {
6 require => {
7 Exception => "IMPL::Exception",
8 ArgumentException => '-IMPL::InvalidArgumentException',
9 ForbiddenException => 'IMPL::Web::ForbiddenException'
10 },
11 base => {
12 'IMPL::Web::Application::RestBaseResource' => '@_'
13 }
14 };
15
16 BEGIN {
17 public property get => PROP_GET | PROP_OWNERSET;
18 public property put => PROP_GET | PROP_OWNERSET;
19 public property post => PROP_GET | PROP_OWNERSET;
20 public property delete => PROP_GET | PROP_OWNERSET;
21 }
22
23 sub CTOR {
24 my ($this) = @_;
25
26 die ArgumentException->new("parent") unless $this->parent;
27 }
28
29 sub FetchChildResource {
30 my ($this,$id,$action) = @_;
31
32 return $this->contract->Transform( $this->GetImpl($action), { parent => $this, id => $id } )->FetchChildResource($id,$action);
33 }
34
35 sub GetImpl {
36 my ($this,$action) = @_;
37
38 my $method = $this->get or die ForbiddenException->new();
39 return $this->$method($action);
40 }
41
42 sub PutImpl {
43 my ($this,$action) = @_;
44 my $method = $this->put or die ForbiddenException->new();
45 return $this->$method($action);
46 }
47
48 sub PostImpl {
49 my ($this,$action) = @_;
50 my $method = $this->post or die ForbiddenException->new();
51 return $this->$method($action);
52 }
53
54 sub DeleteImpl {
55 my ($this,$action) = @_;
56 my $method = $this->delete or die ForbiddenException->new();
57 return $this->$method($action);
58 }
59
60 1;