Mercurial > pub > Impl
diff Lib/IMPL/Web/Application/RestBaseResource.pm @ 201:0c018a247c8a
Reworked REST resource classes to be more transparent and intuitive
author | sergey |
---|---|
date | Tue, 24 Apr 2012 19:52:07 +0400 |
parents | a9dbe534d236 |
children | 5146e17a7b76 |
line wrap: on
line diff
--- a/Lib/IMPL/Web/Application/RestBaseResource.pm Tue Apr 24 02:34:49 2012 +0400 +++ b/Lib/IMPL/Web/Application/RestBaseResource.pm Tue Apr 24 19:52:07 2012 +0400 @@ -22,6 +22,7 @@ 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 { @@ -49,11 +50,11 @@ } sub InvokeHttpMethod { - my ($this,$method,$childId,$action) = @_; + my ($this,$method,$action) = @_; my $impl = $this->GetHttpImpl($method) || 'HttpFallbackImpl'; - return $this->$impl($childId,$action); + return $this->$impl($action); } sub GetImpl { @@ -76,6 +77,10 @@ die ForbiddenException->new(); } +sub FetchChildResource { + return undef; +} + sub InvokeMember { my ($this,$method,$action) = @_; @@ -90,6 +95,7 @@ if (ref $method eq 'HASH') { my $member = $method->{method} or die InvalidOpException->new("A member name isn't specified"); + my @args; if (my $params = $method->{parameters}) { @@ -108,7 +114,7 @@ } elsif (ref $method eq TResolve) { return $method->Invoke($this->target); } elsif (ref $method eq 'CODE') { - return $method->($this->target,$action); + return $method->($this,$action); } else { die InvalidOpException->new("Unsupported type of the method information", ref $method); } @@ -121,13 +127,9 @@ if (is $param, TTransform ) { return $param->Transform($this,$action->query); } elsif ($param and not ref $param) { - my %std = ( - id => $this->id, - action => $action, - query => $action->query - ); - - return $std{$param} || $action->query->param($param); + return $action->query->param($param); + } else { + die new InvalidOpException->new("Unsupported parameter mapping", $param); } } else { return undef; @@ -135,4 +137,12 @@ } -1; \ No newline at end of file +1; + +__END__ + +=pod + + + +=cut \ No newline at end of file