Mercurial > pub > Impl
diff Lib/IMPL/Web/Application/CustomResource.pm @ 330:fe725fad2d90
Added access checking to web resources
author | sergey |
---|---|
date | Tue, 04 Jun 2013 19:25:54 +0400 |
parents | 9b25e1f50144 |
children | 04a093f0a5a6 |
line wrap: on
line diff
--- a/Lib/IMPL/Web/Application/CustomResource.pm Mon Jun 03 18:03:54 2013 +0400 +++ b/Lib/IMPL/Web/Application/CustomResource.pm Tue Jun 04 19:25:54 2013 +0400 @@ -10,12 +10,22 @@ }, base => [ 'IMPL::Web::Application::Resource' => '@_' + ], + props => [ + accessCheck => PROP_RW ] }; __PACKAGE__->static_accessor(contractFactory => CustomResourceContract ); __PACKAGE__->static_accessor_own(_contractInstance => undef); +sub CTOR { + my ($this,%args) = @_; + + $this->accessCheck($args{accessCheck}) + if $args{accessCheck}; +} + sub contractInstance { my ($self) = @_; @@ -51,6 +61,16 @@ $self->CreateContract()->CreateResource(%args); } +sub AccessCheck { + my ($this,$verb) = @_; + + my $handler = $this->accessCheck; + + if(ref($handler) eq 'CODE') { + &$handler($this,$verb); + } +} + sub GetChildResources { }