diff 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
line wrap: on
line diff
--- a/Lib/IMPL/Web/Application/RestCustomResource.pm	Tue Apr 24 02:34:49 2012 +0400
+++ b/Lib/IMPL/Web/Application/RestCustomResource.pm	Tue Apr 24 19:52:07 2012 +0400
@@ -6,7 +6,8 @@
 	require => {
 		Exception => "IMPL::Exception",
 		ArgumentException => '-IMPL::InvalidArgumentException',
-		ForbiddenException => 'IMPL::Web::ForbiddenException'
+		ForbiddenException => 'IMPL::Web::ForbiddenException',
+		NotFoundException => 'IMPL::Web::NotFoundException'
 	},
 	base => {
 		'IMPL::Web::Application::RestBaseResource' => '@_'
@@ -29,6 +30,8 @@
 sub FetchChildResource {
 	my ($this,$id,$action) = @_;
 	
+	die NotFoundException->new() if $this->final;
+	
 	return $this->contract->Transform( $this->GetImpl($action), { parent => $this, id => $id } )->FetchChildResource($id,$action);
 }
 
@@ -36,25 +39,25 @@
 	my ($this,$action) = @_;
 	
 	my $method = $this->get or die ForbiddenException->new();
-	return $this->$method($action);
+	return $this->InvokeMember($method,$action);
 }
 
 sub PutImpl {
 	my ($this,$action) = @_;
 	my $method = $this->put or die ForbiddenException->new();
-    return $this->$method($action);
+    return $this->InvokeMember($method,$action);
 }
 
 sub PostImpl {
 	my ($this,$action) = @_;
 	my $method = $this->post or die ForbiddenException->new();
-    return $this->$method($action);
+    return $this->InvokeMember($method,$action);
 }
 
 sub DeleteImpl {
 	my ($this,$action) = @_;
 	my $method = $this->delete or die ForbiddenException->new();
-    return $this->$method($action);
+    return $this->InvokeMember($method,$action);
 }
 
 1;
\ No newline at end of file