Mercurial > pub > Impl
comparison Lib/IMPL/Web/Application/Action.pm @ 55:609b59c9f03c
Web application
rewrote prop_list implementation to support IMPL::Object::List
author | wizard |
---|---|
date | Wed, 03 Mar 2010 17:40:18 +0300 |
parents | 15d720913562 |
children | 117b6956d5a5 |
comparison
equal
deleted
inserted
replaced
54:f4e045e47770 | 55:609b59c9f03c |
---|---|
1 package IMPL::Web::Application::Action; | 1 package IMPL::Web::Application::Action; |
2 use strict; | |
2 | 3 |
3 use base qw(IMPL::Object); | 4 use base qw(IMPL::Object); |
4 | 5 |
5 use IMPL::Class::Property; | 6 use IMPL::Class::Property; |
6 | 7 |
7 BEGIN { | 8 BEGIN { |
8 public property application => prop_get | owner_set; | 9 public property application => prop_get | owner_set; |
9 public property request => prop_get | owner_set; | 10 public property request => prop_get | owner_set; |
10 public property response => prop_get | owner_set; | 11 public property response => prop_get | owner_set; |
11 public property code => prop_get | owner_set; | 12 |
12 public property chainHandlers => prop_get | owner_set | prop_list; | 13 private property _entryPoint => prop_all; |
14 } | |
15 | |
16 sub Invoke { | |
17 my ($this) = @_; | |
18 | |
19 if ($this->_entryPoint) { | |
20 $this->_entryPoint->(); | |
21 } else { | |
22 die new IMPL::InvalidOperationException("At least one handler is required"); | |
23 } | |
24 } | |
25 | |
26 sub ChainHandler { | |
27 my ($this,$handler) = @_; | |
28 | |
29 my $delegate; | |
30 | |
31 my $delegateNext = $this->_entryPoint(); | |
32 | |
33 if (ref $handler eq 'CODE') { | |
34 $delegate = sub { | |
35 $handler->($this,$delegateNext); | |
36 }; | |
37 } elsif (UNIVERSAL::isa($handler,'IMPL::Web::Application::QueryHandler')) { | |
38 $delegate = sub { | |
39 $handler->Invoke($this,$delegateNext); | |
40 } | |
41 } else { | |
42 die new IMPL::InvalidArgumentException("An invalid handler supplied"); | |
43 } | |
44 | |
13 } | 45 } |
14 | 46 |
15 1; | 47 1; |
16 | 48 |
17 __END__ | 49 __END__ |