Mercurial > pub > Impl
diff 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 |
line wrap: on
line diff
--- a/Lib/IMPL/Web/Application/Action.pm Fri Mar 12 16:23:46 2010 +0300 +++ b/Lib/IMPL/Web/Application/Action.pm Mon Mar 15 02:38:09 2010 +0300 @@ -3,6 +3,8 @@ use base qw(IMPL::Object IMPL::Object::Autofill); +__PACKAGE__->PassThroughArgs; + use IMPL::Class::Property; BEGIN { @@ -13,6 +15,8 @@ private property _entryPoint => prop_all; } +#todo: make ability to discard old and create new response + sub Invoke { my ($this) = @_; @@ -32,18 +36,32 @@ $this->_entryPoint( sub { $handler->($this,$delegateNext); } ); - } elsif (UNIVERSAL::isa($handler,'IMPL::Web::Application::QueryHandler')) { + } elsif (ref $handler and UNIVERSAL::isa($handler,'IMPL::Web::QueryHandler')) { $this->_entryPoint( sub { $handler->Invoke($this,$delegateNext); } ); } elsif ($handler and not ref $handler) { - my $method = $this->can($handler) or die new IMPL::InvalidArgumentException("An invalid handler supplied"); - $this->_entryPoint( sub { - $method->($this,$delegateNext); - } ); + if (my $method = $this->can($handler) ) { + $this->_entryPoint( sub { + $method->($this,$delegateNext); + } ); + } else { + { + no strict 'refs'; + eval "require $handler; 1;" or die new IMPL::InvalidArgumentException("An invalid handler supplied",$handler,"Failed to load module") unless keys %{"${handler}::"}; + } + + if (UNIVERSAL::isa($handler,'IMPL::Web::QueryHandler')) { + $this->_entryPoint( sub { + $handler->Invoke($this,$delegateNext); + } ); + } else { + die new IMPL::InvalidArgumentException("An invalid handler supplied",$handler); + } + } } else { - die new IMPL::InvalidArgumentException("An invalid handler supplied"); + die new IMPL::InvalidArgumentException("An invalid handler supplied",$handler); } }