Mercurial > pub > Impl
comparison Lib/IMPL/Web/Application/RestCustomResource.pm @ 201:0c018a247c8a
Reworked REST resource classes to be more transparent and intuitive
author | sergey |
---|---|
date | Tue, 24 Apr 2012 19:52:07 +0400 |
parents | a9dbe534d236 |
children | 5146e17a7b76 |
comparison
equal
deleted
inserted
replaced
200:a9dbe534d236 | 201:0c018a247c8a |
---|---|
4 use IMPL::lang qw(:declare :constants); | 4 use IMPL::lang qw(:declare :constants); |
5 use IMPL::declare { | 5 use IMPL::declare { |
6 require => { | 6 require => { |
7 Exception => "IMPL::Exception", | 7 Exception => "IMPL::Exception", |
8 ArgumentException => '-IMPL::InvalidArgumentException', | 8 ArgumentException => '-IMPL::InvalidArgumentException', |
9 ForbiddenException => 'IMPL::Web::ForbiddenException' | 9 ForbiddenException => 'IMPL::Web::ForbiddenException', |
10 NotFoundException => 'IMPL::Web::NotFoundException' | |
10 }, | 11 }, |
11 base => { | 12 base => { |
12 'IMPL::Web::Application::RestBaseResource' => '@_' | 13 'IMPL::Web::Application::RestBaseResource' => '@_' |
13 } | 14 } |
14 }; | 15 }; |
27 } | 28 } |
28 | 29 |
29 sub FetchChildResource { | 30 sub FetchChildResource { |
30 my ($this,$id,$action) = @_; | 31 my ($this,$id,$action) = @_; |
31 | 32 |
33 die NotFoundException->new() if $this->final; | |
34 | |
32 return $this->contract->Transform( $this->GetImpl($action), { parent => $this, id => $id } )->FetchChildResource($id,$action); | 35 return $this->contract->Transform( $this->GetImpl($action), { parent => $this, id => $id } )->FetchChildResource($id,$action); |
33 } | 36 } |
34 | 37 |
35 sub GetImpl { | 38 sub GetImpl { |
36 my ($this,$action) = @_; | 39 my ($this,$action) = @_; |
37 | 40 |
38 my $method = $this->get or die ForbiddenException->new(); | 41 my $method = $this->get or die ForbiddenException->new(); |
39 return $this->$method($action); | 42 return $this->InvokeMember($method,$action); |
40 } | 43 } |
41 | 44 |
42 sub PutImpl { | 45 sub PutImpl { |
43 my ($this,$action) = @_; | 46 my ($this,$action) = @_; |
44 my $method = $this->put or die ForbiddenException->new(); | 47 my $method = $this->put or die ForbiddenException->new(); |
45 return $this->$method($action); | 48 return $this->InvokeMember($method,$action); |
46 } | 49 } |
47 | 50 |
48 sub PostImpl { | 51 sub PostImpl { |
49 my ($this,$action) = @_; | 52 my ($this,$action) = @_; |
50 my $method = $this->post or die ForbiddenException->new(); | 53 my $method = $this->post or die ForbiddenException->new(); |
51 return $this->$method($action); | 54 return $this->InvokeMember($method,$action); |
52 } | 55 } |
53 | 56 |
54 sub DeleteImpl { | 57 sub DeleteImpl { |
55 my ($this,$action) = @_; | 58 my ($this,$action) = @_; |
56 my $method = $this->delete or die ForbiddenException->new(); | 59 my $method = $this->delete or die ForbiddenException->new(); |
57 return $this->$method($action); | 60 return $this->InvokeMember($method,$action); |
58 } | 61 } |
59 | 62 |
60 1; | 63 1; |