| 1 | package SVN::Access::Resource; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use 5.006001; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Tie::IxHash; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 1 | our $VERSION = '0.10'; | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | sub new { | ||||||||||||||||||||||||||||
| 12 | 28 | ▶ | my ($class, %attr) = @_; | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | # keep our hashes in order. Thanks Kage of HackThisSite.org | ||||||||||||||||||||||||||||
| 15 | 28 | my (%authorized, $t); | |||||||||||||||||||||||||||
| 16 | 28 | $t = tie(%authorized, 'Tie::IxHash'); | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | # make sure we copy in stuff that was passed. | ||||||||||||||||||||||||||||
| 19 | 28 | %authorized = (@{$attr{authorized}}); | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 28 | $attr{authorized} = \%authorized; | |||||||||||||||||||||||||||
| 22 | 28 | $attr{_authorized_tie} = $t; | |||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 28 | return bless(\%attr, $class); | |||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | sub authorized { | ||||||||||||||||||||||||||||
| 28 | 90 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
authorized: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||
| 29 | 90 | ▶ | if (ref ($self->{authorized}) eq "HASH") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | 90 | return $self->{authorized}; | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | 0 | return undef; | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | sub is_authorized { | ||||||||||||||||||||||||||||
| 36 | 0 | ▶ | my ($self, $entity) = @_; | ||||||||||||||||||||||||||
|
Subroutine
is_authorized: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 37 | 0 | ▶ | if (defined($self->{authorized}) && exists($self->{authorized}->{$entity})) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $self->{"authorized"} and exists $self->{"authorized"}{$entity}
MC/DC0%0/2
defined $self->{"authorized"} and exists $self->{"authorized"}{$entity}
defined $self->{"authorized"}
exists $self->{"authorized"}{$entity}
Truth table0%0/3
A and B
A= defined $self->{"authorized"}B= exists $self->{"authorized"}{$entity}
| |||||||||||||||||||||||||||||
| 38 | 0 | return 1; | |||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | 0 | return undef; | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | sub authorize { | ||||||||||||||||||||||||||||
| 44 | 38 | ▶ | my ($self, @rest) = @_; | ||||||||||||||||||||||||||
|
Subroutine
authorize: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 38 | ▶ | if ($rest[$#rest] =~ /^\d+$/o) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | 1 | $self->{_authorized_tie}->Splice($rest[$#rest], 0, @rest[0..$#rest - 1]); | |||||||||||||||||||||||||||
| 48 | } else { | ||||||||||||||||||||||||||||
| 49 | 37 | $self->{_authorized_tie}->Push(@rest); | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | sub deauthorize { | ||||||||||||||||||||||||||||
| 54 | 0 | ▶ | my ($self, $entity) = @_; | ||||||||||||||||||||||||||
|
Subroutine
deauthorize: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 55 | 0 | ▶ | delete ($self->{authorized}->{$entity}) if ref($self->{authorized}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | sub name { | ||||||||||||||||||||||||||||
| 59 | 236 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 60 | 236 | return $self->{name}; | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 1 | 1; | |||||||||||||||||||||||||||
| 64 | __END__ | ||||||||||||||||||||||||||||