annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
226
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
1 package IMPL::Web::Application::ResourceContract;
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
2 use strict;
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
3 use IMPL::lang qw(:declare);
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
4 use IMPL::declare {
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
5 base => [
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
6 'IMPL::Object' => undef
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
7 ]
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
8 };
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
9
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
10 BEGIN {
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
11 public property operations => PROP_ALL;
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
12 private property _namedResources => PROP_ALL;
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
13 private property _regexpResources => PROP_ALL;
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
14 }
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
15
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
16 1;
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
17
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
18 __END__
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
19
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
20 =pod
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
21
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
22 =head1 NAME
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
23
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
24 C<IMPL::Web::Application::ResourceContract> - описание ресурса
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
25
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
26 =head1 SYNIOSIS
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
27
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
28 =begin code
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
29
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
30 use IMPL::require {
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
31 ResourceContract => 'IMPL::Web::Application::ResourceContract',
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
32 OperationContract => 'IMPL::Web::Application::OperationContract'
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
33 };
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
34
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
35 my $contract = ResourceContract->new(
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
36 operations => {
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
37 get => OperationContract->new(
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
38 bind => sub {
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
39 return "Hello!";
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
40 }
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
41 )
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
42 },
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
43 resources => [
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
44 {
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
45 name => 'info',
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
46 bind => sub {
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
47 return $_[0]->model->info;
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
48 },
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
49 contract => ResourceContract->new(
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
50 get => OperationContract->new(
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
51 bind => sub {
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
52 my ($resource,$model) = @_;
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
53 return $model; # or the same: $resource->model;
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
54 }
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
55 )
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
56 )
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
57 }
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
58 ]
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
59 )
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
60
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
61 =end code
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
62
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
63 =head1 DESCRIPTION
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
64
b6cde007a175 Added resource contract
sergey
parents:
diff changeset
65 =cut