Mercurial > pub > Impl
diff Lib/IMPL/Web/Application/OperationContract.pm @ 230:6d8092d8ce1b
*reworked IMPL::Security
*reworked IMPL::Web::Security
*refactoring
author | sergey |
---|---|
date | Mon, 08 Oct 2012 03:37:37 +0400 |
parents | 47f77e6409f7 |
children | 4abda21186cd |
line wrap: on
line diff
--- a/Lib/IMPL/Web/Application/OperationContract.pm Sat Sep 29 02:34:47 2012 +0400 +++ b/Lib/IMPL/Web/Application/OperationContract.pm Mon Oct 08 03:37:37 2012 +0400 @@ -4,9 +4,9 @@ use IMPL::lang qw(:declare); use IMPL::declare { require => { - 'Exception' => 'IMPL::Exception', - 'ArgumentException' => '-IMPL::ArgumentException', - 'ResourceBaseClass' => 'IMPL::Web::Application::ResourceBase' + Exception => 'IMPL::Exception', + ArgumentException => '-IMPL::InvalidArgumentException', + ResourceInterface => 'IMPL::Web::Application::ResourceInterface' }, base => [ 'IMPL::Object' => undef, @@ -22,17 +22,23 @@ sub Invoke { my ( $this, $resource, $request ) = @_; - die ArgumentException( resource => 'A valid resource is required' ) - unless eval { $resource->isa(ResourceBaseClass) }; - + die ArgumentException->new( resource => 'A valid resource is required' ) + unless eval { $resource->isa(ResourceInterface) }; + my $result = eval { _InvokeDelegate($this->binding, $resource, $request) }; if (my $e = $@) { - $result = _InvokeDelegate($this->error, $resource, $request, $e); + if ($this->error) { + $result = _InvokeDelegate($this->error, $resource, $request, $e) ; + } else { + die $e; + } + } else { - $result = _InvokeDelegate($this->success, $resource, $request, $result); + $result = _InvokeDelegate($this->success, $resource, $request, $result) + if ($this->success); } return $result; @@ -41,7 +47,7 @@ sub _InvokeDelegate { my $delegate = shift; - return $delegete->(@_) if ref $delegate eq 'CODE'; + return $delegate->(@_) if ref $delegate eq 'CODE'; return $delegate->Invoke(@_) if eval { $delegate->can('Invoke')}; }