annotate Lib/IMPL/Web/Application/ControllerUnit.pm @ 110:c13a215508ca

Refactoring, ControllerUnit
author wizard
date Mon, 17 May 2010 17:42:27 +0400
parents
children 6c25ea91c985
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
110
c13a215508ca Refactoring,
wizard
parents:
diff changeset
1 package IMPL::Web::Application::ControllerUnit;
c13a215508ca Refactoring,
wizard
parents:
diff changeset
2
c13a215508ca Refactoring,
wizard
parents:
diff changeset
3 use base qw(IMPL::Object);
c13a215508ca Refactoring,
wizard
parents:
diff changeset
4
c13a215508ca Refactoring,
wizard
parents:
diff changeset
5 use IMPL::Class::Property;
c13a215508ca Refactoring,
wizard
parents:
diff changeset
6
c13a215508ca Refactoring,
wizard
parents:
diff changeset
7 BEGIN {
c13a215508ca Refactoring,
wizard
parents:
diff changeset
8 public property action => prop_get | owner_set;
c13a215508ca Refactoring,
wizard
parents:
diff changeset
9 public property application => prop_get | owner_set;
c13a215508ca Refactoring,
wizard
parents:
diff changeset
10 public property query => prop_get | owner_set;
c13a215508ca Refactoring,
wizard
parents:
diff changeset
11 }
c13a215508ca Refactoring,
wizard
parents:
diff changeset
12
c13a215508ca Refactoring,
wizard
parents:
diff changeset
13 sub CTOR {
c13a215508ca Refactoring,
wizard
parents:
diff changeset
14 my ($this,$action) = @_;
c13a215508ca Refactoring,
wizard
parents:
diff changeset
15
c13a215508ca Refactoring,
wizard
parents:
diff changeset
16 $this->action($action);
c13a215508ca Refactoring,
wizard
parents:
diff changeset
17 $this->application($action->application);
c13a215508ca Refactoring,
wizard
parents:
diff changeset
18 $this->query($action->query);
c13a215508ca Refactoring,
wizard
parents:
diff changeset
19 }
c13a215508ca Refactoring,
wizard
parents:
diff changeset
20
c13a215508ca Refactoring,
wizard
parents:
diff changeset
21 sub InvokeAction {
c13a215508ca Refactoring,
wizard
parents:
diff changeset
22 my ($self,$method,$action) = @_;
c13a215508ca Refactoring,
wizard
parents:
diff changeset
23
c13a215508ca Refactoring,
wizard
parents:
diff changeset
24 if ($self->can($method)) {
c13a215508ca Refactoring,
wizard
parents:
diff changeset
25 my $unit = $self->new($action);
c13a215508ca Refactoring,
wizard
parents:
diff changeset
26 $unit->$method();
c13a215508ca Refactoring,
wizard
parents:
diff changeset
27 } else {
c13a215508ca Refactoring,
wizard
parents:
diff changeset
28 die new IMPL::InvalidOperationException("Invalid method call",$self,$method);
c13a215508ca Refactoring,
wizard
parents:
diff changeset
29 }
c13a215508ca Refactoring,
wizard
parents:
diff changeset
30 }