Mercurial > pub > Impl
view Lib/IMPL/Web/Application/RestBaseResource.pm @ 202:5146e17a7b76
IMPL::Web::Application::RestResource fixes, documentation
author | sergey |
---|---|
date | Wed, 25 Apr 2012 02:49:23 +0400 |
parents | 0c018a247c8a |
children | c8fe3f84feba |
line wrap: on
line source
package IMPL::Web::Application::RestBaseResource; use strict; use IMPL::lang qw(:declare :constants); use IMPL::declare { require => { Exception => 'IMPL::Exception', ArgumentException => '-IMPL::InvalidArgumentException', NotImplException => '-IMPL::NotImplementedException', ForbiddenException => 'IMPL::Web::ForbiddenException', TTransform => '-IMPL::Transform', TResolve => '-IMPL::Config::Resolve' }, base => { 'IMPL::Object' => undef, 'IMPL::Object::Autofill' => '@_' } }; BEGIN { public property id => PROP_GET | PROP_OWNERSET; public property parent => PROP_GET | PROP_OWNERSET; public property contract => PROP_GET | PROP_OWNERSET; protected property final => PROP_ALL; } sub target { shift; } sub CTOR { my ($this) = @_; die ArgumentException->new("id","Identifier is required for non-root resources") if $this->id and not length $this->id; die ArgumentException->new("A contract is required") unless $this->contract; } sub GetHttpImpl { my($this,$method) = @_; my %map = ( GET => 'GetImpl', PUT => 'PutImpl', POST => 'PostImpl', DELETE => 'DeleteImpl' ); return $map{$method}; } sub InvokeHttpMethod { my ($this,$method,$action) = @_; my $impl = $this->GetHttpImpl($method) || 'HttpFallbackImpl'; return $this->$impl($action); } sub GetImpl { die NotImplException->new(); } sub PutImpl { die NotImplException->new(); } sub PostImpl { die NotImplException->new(); } sub DeleteImpl { die NotImplException->new(); } sub HttpFallbackImpl { die ForbiddenException->new(); } sub FetchChildResource { return undef; } 1; __END__ =pod =cut