File Coverage

blib/lib/SVN/Access/Resource.pm
Criterion Covered Total %
statement 29 36 80.5
branch 3 8 37.5
condition 0 3 0.0
subroutine 8 10 80.0
pod 5 6 83.3
total 45 63 71.4


line stmt bran cond sub pod time code
1             package SVN::Access::Resource;
2              
3 1     1   14 use 5.006001;
  1         2  
  1         32  
4 1     1   3 use strict;
  1         1  
  1         22  
5 1     1   3 use warnings;
  1         1  
  1         19  
6              
7 1     1   703 use Tie::IxHash;
  1         4403  
  1         443  
8              
9             our $VERSION = '0.10';
10              
11             sub new {
12 28     28 1 117 my ($class, %attr) = @_;
13              
14             # keep our hashes in order. Thanks Kage of HackThisSite.org
15 28         30 my (%authorized, $t);
16 28         143 $t = tie(%authorized, 'Tie::IxHash');
17            
18             # make sure we copy in stuff that was passed.
19 28         357 %authorized = (@{$attr{authorized}});
  28         139  
20            
21 28         578 $attr{authorized} = \%authorized;
22 28         53 $attr{_authorized_tie} = $t;
23            
24 28         110 return bless(\%attr, $class);
25             }
26              
27             sub authorized {
28 90     90 1 106 my ($self) = @_;
29 90 50       206 if (ref ($self->{authorized}) eq "HASH") {
30 90         374 return $self->{authorized};
31             }
32 0         0 return undef;
33             }
34              
35             sub is_authorized {
36 0     0 0 0 my ($self, $entity) = @_;
37 0 0 0     0 if (defined($self->{authorized}) && exists($self->{authorized}->{$entity})) {
38 0         0 return 1;
39             }
40 0         0 return undef;
41             }
42              
43             sub authorize {
44 38     38 1 95 my ($self, @rest) = @_;
45              
46 38 100       158 if ($rest[$#rest] =~ /^\d+$/o) {
47 1         10 $self->{_authorized_tie}->Splice($rest[$#rest], 0, @rest[0..$#rest - 1]);
48             } else {
49 37         122 $self->{_authorized_tie}->Push(@rest);
50             }
51             }
52              
53             sub deauthorize {
54 0     0 1 0 my ($self, $entity) = @_;
55 0 0       0 delete ($self->{authorized}->{$entity}) if ref($self->{authorized});
56             }
57              
58             sub name {
59 236     236 1 250 my ($self) = @_;
60 236         1089 return $self->{name};
61             }
62              
63             1;
64             __END__