Mercurial > pub > Impl
comparison Lib/IMPL/Web/Application/ResourceContract.pm @ 330:fe725fad2d90
Added access checking to web resources
author | sergey |
---|---|
date | Tue, 04 Jun 2013 19:25:54 +0400 |
parents | 673581380e79 |
children | 2ff1726c066c |
comparison
equal
deleted
inserted
replaced
329:50ff1595bd62 | 330:fe725fad2d90 |
---|---|
6 use IMPL::declare { | 6 use IMPL::declare { |
7 require => { | 7 require => { |
8 Exception => 'IMPL::Exception', | 8 Exception => 'IMPL::Exception', |
9 ArgumentException => '-IMPL::ArgumentException', | 9 ArgumentException => '-IMPL::ArgumentException', |
10 KeyNotFoundException => '-IMPL::KeyNotFoundException', | 10 KeyNotFoundException => '-IMPL::KeyNotFoundException', |
11 ResourceClass => 'IMPL::Web::Application::Resource' | 11 ResourceClass => 'IMPL::Web::Application::CustomResource', |
12 CustomContract => 'IMPL::Web::Application::CustomResourceContract', | |
13 Factory => 'IMPL::Object::Factory' | |
12 }, | 14 }, |
13 base => [ 'IMPL::Object' => undef ], | 15 base => [ 'IMPL::Object' => undef ], |
14 props => [ | 16 props => [ |
15 resourceFactory => PROP_ALL, | 17 resourceFactory => PROP_ALL, |
16 verbs => PROP_ALL, | 18 verbs => PROP_ALL, |
21 | 23 |
22 sub CTOR { | 24 sub CTOR { |
23 my $this = shift; | 25 my $this = shift; |
24 my %args = @_; | 26 my %args = @_; |
25 | 27 |
26 $this->resourceFactory( $args{resourceFactory} || ResourceClass ); | 28 my $factory = delete $args{resourceFactory} || ResourceClass; |
27 | 29 my $resources = delete $args{resources} || []; |
28 my $resources = $args{resources} || []; | 30 my $verbs = delete $args{verbs} || {}; |
29 my $verbs = $args{verbs} || {}; | |
30 | 31 |
31 die ArgumentException->new( | 32 die ArgumentException->new( |
32 resources => 'resources parameter must be a reference to an array' ) | 33 resources => 'resources parameter must be a reference to an array' ) |
33 unless ref $resources eq 'ARRAY'; | 34 unless ref $resources eq 'ARRAY'; |
34 | 35 |
55 $this->_regexpResources->Append($res); | 56 $this->_regexpResources->Append($res); |
56 } | 57 } |
57 } | 58 } |
58 | 59 |
59 $this->_namedResources( \%nameMap ); | 60 $this->_namedResources( \%nameMap ); |
61 | |
62 $this->resourceFactory( %args ? Factory->new($factory,\%args) : $factory ); | |
60 } | 63 } |
61 | 64 |
62 sub AddChildResourceContract { | 65 sub AddChildResourceContract { |
63 my ($this,$res) = @_; | 66 my ($this,$res) = @_; |
64 | 67 |