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

sync
author sergey
date Tue, 24 Apr 2012 02:34:49 +0400
parents
children 0c018a247c8a
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Lib/IMPL/Web/Application/RestCustomResource.pm	Tue Apr 24 02:34:49 2012 +0400
@@ -0,0 +1,60 @@
+package IMPL::Web::Application::RestCustomResource;
+use strict;
+
+use IMPL::lang qw(:declare :constants);
+use IMPL::declare {
+	require => {
+		Exception => "IMPL::Exception",
+		ArgumentException => '-IMPL::InvalidArgumentException',
+		ForbiddenException => 'IMPL::Web::ForbiddenException'
+	},
+	base => {
+		'IMPL::Web::Application::RestBaseResource' => '@_'
+	}
+};
+
+BEGIN {
+	public property get => PROP_GET | PROP_OWNERSET;
+	public property put => PROP_GET | PROP_OWNERSET;
+	public property post => PROP_GET | PROP_OWNERSET;
+	public property delete => PROP_GET | PROP_OWNERSET;
+}
+
+sub CTOR {
+	my ($this) = @_;
+	
+	die ArgumentException->new("parent") unless $this->parent; 
+}
+
+sub FetchChildResource {
+	my ($this,$id,$action) = @_;
+	
+	return $this->contract->Transform( $this->GetImpl($action), { parent => $this, id => $id } )->FetchChildResource($id,$action);
+}
+
+sub GetImpl {
+	my ($this,$action) = @_;
+	
+	my $method = $this->get or die ForbiddenException->new();
+	return $this->$method($action);
+}
+
+sub PutImpl {
+	my ($this,$action) = @_;
+	my $method = $this->put or die ForbiddenException->new();
+    return $this->$method($action);
+}
+
+sub PostImpl {
+	my ($this,$action) = @_;
+	my $method = $this->post or die ForbiddenException->new();
+    return $this->$method($action);
+}
+
+sub DeleteImpl {
+	my ($this,$action) = @_;
+	my $method = $this->delete or die ForbiddenException->new();
+    return $this->$method($action);
+}
+
+1;
\ No newline at end of file