annotate Lib/IMPL/Web/Application/CustomResource.pm @ 229:47f77e6409f7

heavily reworked the resource model of the web application: *some ResourcesContraact functionality moved to Resource +Added CustomResource *Corrected action handlers
author sergey
date Sat, 29 Sep 2012 02:34:47 +0400
parents
children 6d8092d8ce1b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
229
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
1 package IMPL::Web::Application::CustomResource;
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
2 use strict;
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
3
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
4 use IMPL::lang qw(:constants);
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
5
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
6 use IMPL::declare {
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
7 require => {
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
8 CustomResourceContract => 'IMPL::Web::Application::CustomResourceContract'
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
9 },
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
10 base => [
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
11 'IMPL::Web::Application::Resource' => '@_'
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
12 ]
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
13 };
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
14
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
15 __PACKAGE__->static_accessor(contractFactory => CustomResourceContract );
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
16 __PACKAGE__->static_accessor_own(_contractInstance => undef);
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
17
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
18 sub contractInstance {
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
19 my ($self) = @_;
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
20
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
21 $self = ref $self || $self;
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
22 $self->_contractInstance ? $self->_contractInstance : $self->InitContract();
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
23 }
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
24
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
25 sub InitContract {
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
26 my ($self) = @_;
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
27
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
28 $self->_contractInstance( $self->contractFactory->new(resourceFactory => $self ) );
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
29 }
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
30
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
31 sub GetChildResources {
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
32
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
33 }
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
34
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
35
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
36 1;
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
37
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
38 __END__
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
39
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
40 =pod
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
41
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
42 =head1 NAME
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
43
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
44 C<IMPL::Web::Application::CustomResource> - базовый класс для ресурсов,
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
45 реальзуемых в коде.
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
46
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
47 =head1 SYNOPSIS
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
48
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
49 =begin code
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
50
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
51 package MyApp::Web::Resources::ProfileResource;
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
52 use IMPL::declare {
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
53 base => [
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
54 'IMPL::Web::Application::CustomResource' => '@_'
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
55 ]
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
56 }
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
57
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
58 sub HttpGet {
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
59 my ($this) = @_;
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
60 return $this->model;
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
61 }
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
62
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
63 sub HttpPut {
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
64 my ($this,$action) = @_;
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
65
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
66 my $form = MyApp::Web::Schema::UpdateUser->new();
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
67
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
68 $this->model->update( $form->Bind($action) );
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
69 }
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
70
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
71 =end code
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
72
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
73 =head1 MEMBERS
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
74
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
75 =head2 C<[static]contractFactory>
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
76
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
77 Фабрика, используемая для получения контракта ресурса. По умолчанию
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
78 C<IMPL::Web::Application::CustomResourceContract>.
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
79
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
80 =head2 C<[static]contractInstance>
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
81
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
82 Экземпляр контракта для ресурса. Создается при первом обращении при помощи
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
83 метода C<InitContract()>.
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
84
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
85 =head2 C<[static]InitContract()>
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
86
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
87 Создает новый экземпляр контракта, используя фабрику из свойства C<contractFactory>.
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
88
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
89 =head2 C<[static]GetChildResources()>
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
90
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
91 Статический метод, который должны переопределять новые классы ресурсов, у
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
92 которых есть дочерние ресурсы.
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
93
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
94 =begin code
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
95
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
96 package MyApp::Web::MyResource
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
97
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
98 sub GetChildResources {
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
99 my $self = shift;
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
100 return
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
101 $self->SUPER::GetChildResources(),
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
102 {
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
103
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
104 }
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
105 {
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
106
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
107 };
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
108 }
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
109
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
110 =end code
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
111
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
112
47f77e6409f7 heavily reworked the resource model of the web application:
sergey
parents:
diff changeset
113 =cut