comparison Lib/IMPL/Web/Application/Action.pm @ 63:76b878ad6596

Added serialization support for the IMPL::Object::List More intelligent Exception message Fixed encoding support in the actions Improoved tests Minor fixes
author wizard
date Mon, 15 Mar 2010 02:38:09 +0300
parents c64bd1bf727d
children 2840c4c85db8
comparison
equal deleted inserted replaced
62:c64bd1bf727d 63:76b878ad6596
1 package IMPL::Web::Application::Action; 1 package IMPL::Web::Application::Action;
2 use strict; 2 use strict;
3 3
4 use base qw(IMPL::Object IMPL::Object::Autofill); 4 use base qw(IMPL::Object IMPL::Object::Autofill);
5
6 __PACKAGE__->PassThroughArgs;
5 7
6 use IMPL::Class::Property; 8 use IMPL::Class::Property;
7 9
8 BEGIN { 10 BEGIN {
9 public property application => prop_get | owner_set; 11 public property application => prop_get | owner_set;
10 public property query => prop_get | owner_set; 12 public property query => prop_get | owner_set;
11 public property response => prop_get | owner_set; 13 public property response => prop_get | owner_set;
12 14
13 private property _entryPoint => prop_all; 15 private property _entryPoint => prop_all;
14 } 16 }
17
18 #todo: make ability to discard old and create new response
15 19
16 sub Invoke { 20 sub Invoke {
17 my ($this) = @_; 21 my ($this) = @_;
18 22
19 if ($this->_entryPoint) { 23 if ($this->_entryPoint) {
30 34
31 if (ref $handler eq 'CODE') { 35 if (ref $handler eq 'CODE') {
32 $this->_entryPoint( sub { 36 $this->_entryPoint( sub {
33 $handler->($this,$delegateNext); 37 $handler->($this,$delegateNext);
34 } ); 38 } );
35 } elsif (UNIVERSAL::isa($handler,'IMPL::Web::Application::QueryHandler')) { 39 } elsif (ref $handler and UNIVERSAL::isa($handler,'IMPL::Web::QueryHandler')) {
36 $this->_entryPoint( sub { 40 $this->_entryPoint( sub {
37 $handler->Invoke($this,$delegateNext); 41 $handler->Invoke($this,$delegateNext);
38 } ); 42 } );
39 } elsif ($handler and not ref $handler) { 43 } elsif ($handler and not ref $handler) {
40 my $method = $this->can($handler) or die new IMPL::InvalidArgumentException("An invalid handler supplied");
41 44
42 $this->_entryPoint( sub { 45 if (my $method = $this->can($handler) ) {
43 $method->($this,$delegateNext); 46 $this->_entryPoint( sub {
44 } ); 47 $method->($this,$delegateNext);
48 } );
49 } else {
50 {
51 no strict 'refs';
52 eval "require $handler; 1;" or die new IMPL::InvalidArgumentException("An invalid handler supplied",$handler,"Failed to load module") unless keys %{"${handler}::"};
53 }
54
55 if (UNIVERSAL::isa($handler,'IMPL::Web::QueryHandler')) {
56 $this->_entryPoint( sub {
57 $handler->Invoke($this,$delegateNext);
58 } );
59 } else {
60 die new IMPL::InvalidArgumentException("An invalid handler supplied",$handler);
61 }
62 }
45 } else { 63 } else {
46 die new IMPL::InvalidArgumentException("An invalid handler supplied"); 64 die new IMPL::InvalidArgumentException("An invalid handler supplied",$handler);
47 } 65 }
48 66
49 } 67 }
50 68
51 1; 69 1;