comparison 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
comparison
equal deleted inserted replaced
329:50ff1595bd62 330:fe725fad2d90
8 Factory => 'IMPL::Object::Factory', 8 Factory => 'IMPL::Object::Factory',
9 CustomResourceContract => 'IMPL::Web::Application::CustomResourceContract' 9 CustomResourceContract => 'IMPL::Web::Application::CustomResourceContract'
10 }, 10 },
11 base => [ 11 base => [
12 'IMPL::Web::Application::Resource' => '@_' 12 'IMPL::Web::Application::Resource' => '@_'
13 ],
14 props => [
15 accessCheck => PROP_RW
13 ] 16 ]
14 }; 17 };
15 18
16 __PACKAGE__->static_accessor(contractFactory => CustomResourceContract ); 19 __PACKAGE__->static_accessor(contractFactory => CustomResourceContract );
17 __PACKAGE__->static_accessor_own(_contractInstance => undef); 20 __PACKAGE__->static_accessor_own(_contractInstance => undef);
21
22 sub CTOR {
23 my ($this,%args) = @_;
24
25 $this->accessCheck($args{accessCheck})
26 if $args{accessCheck};
27 }
18 28
19 sub contractInstance { 29 sub contractInstance {
20 my ($self) = @_; 30 my ($self) = @_;
21 31
22 $self = ref $self || $self; 32 $self = ref $self || $self;
47 57
48 sub CreateResource { 58 sub CreateResource {
49 my ($self,%args) = @_; 59 my ($self,%args) = @_;
50 60
51 $self->CreateContract()->CreateResource(%args); 61 $self->CreateContract()->CreateResource(%args);
62 }
63
64 sub AccessCheck {
65 my ($this,$verb) = @_;
66
67 my $handler = $this->accessCheck;
68
69 if(ref($handler) eq 'CODE') {
70 &$handler($this,$verb);
71 }
52 } 72 }
53 73
54 sub GetChildResources { 74 sub GetChildResources {
55 75
56 } 76 }