diff Lib/IMPL/Web/Application/ResourceContract.pm @ 226:b6cde007a175

Added resource contract
author sergey
date Wed, 05 Sep 2012 15:10:26 +0400
parents
children 70ad6bc20908
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Lib/IMPL/Web/Application/ResourceContract.pm	Wed Sep 05 15:10:26 2012 +0400
@@ -0,0 +1,65 @@
+package IMPL::Web::Application::ResourceContract;
+use strict;
+use IMPL::lang qw(:declare);
+use IMPL::declare {
+	base => [
+	   'IMPL::Object' => undef
+	]
+};
+
+BEGIN {
+	public property operations => PROP_ALL;
+	private property _namedResources => PROP_ALL;
+	private property _regexpResources => PROP_ALL; 
+}
+
+1;
+
+__END__
+
+=pod
+
+=head1 NAME
+
+C<IMPL::Web::Application::ResourceContract> - описание ресурса
+
+=head1 SYNIOSIS
+
+=begin code
+
+use IMPL::require {
+	ResourceContract => 'IMPL::Web::Application::ResourceContract',
+	OperationContract => 'IMPL::Web::Application::OperationContract'
+};
+
+my $contract = ResourceContract->new(
+    operations => {
+    	get => OperationContract->new(
+            bind => sub {
+                return "Hello!";
+            }
+        )
+    },
+    resources => [
+        {
+        	name => 'info',
+        	bind => sub {
+        		return $_[0]->model->info;
+        	},
+        	contract => ResourceContract->new(
+        	   get => OperationContract->new(
+        	       bind => sub {
+        	       	   my ($resource,$model) = @_;
+        	       	   return $model; # or the same: $resource->model;
+        	       }
+        	   )
+        	)
+        }
+    ]
+)
+
+=end code 
+
+=head1 DESCRIPTION
+
+=cut
\ No newline at end of file