| 1 | package Set::NestedGroups::MemberList; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 1 | ▶ | use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 1 | @ISA = qw(); | |||||||||||||||||||
| 7 | # Items to export into callers namespace by default. Note: do not export | ||||||||||||||||||||
| 8 | # names by default without a very good reason. Use EXPORT_OK instead. | ||||||||||||||||||||
| 9 | # Do not simply export all your public functions/methods/constants. | ||||||||||||||||||||
| 10 | 1 | @EXPORT = qw( | |||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | ); | ||||||||||||||||||||
| 13 | 1 | $VERSION = '0.01'; | |||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | # Preloaded methods go here. | ||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 0 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 18 | 0 | my $proto=shift; | |||||||||||||||||||
| 19 | 0 | ▶ | my $class=ref($proto) || $proto; | ||||||||||||||||||
|
Condition0%0/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table0%0/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||
| 20 | 0 | my $self ={}; | |||||||||||||||||||
| 21 | 0 | $self->{'COUNT'}= 0; | |||||||||||||||||||
| 22 | 0 | bless($self,$class); | |||||||||||||||||||
| 23 | 0 | return $self; | |||||||||||||||||||
| 24 | } | ||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | 0 | ▶ | sub add { | ||||||||||||||||||
|
Subroutine
add: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 27 | 0 | my $self=shift; | |||||||||||||||||||
| 28 | 0 | my ($member,$group)=@_; | |||||||||||||||||||
| 29 | 0 | push(@{$self->{'LIST'}},$member); | |||||||||||||||||||
| 30 | 0 | push(@{$self->{'LIST'}},$group); | |||||||||||||||||||
| 31 | 0 | $self->{'COUNT'}++; | |||||||||||||||||||
| 32 | } | ||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | 0 | ▶ | sub next { | ||||||||||||||||||
|
Subroutine
next: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 35 | 0 | my $self=shift; | |||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | 0 | my $member=shift(@{$self->{'LIST'}}); | |||||||||||||||||||
| 38 | 0 | my $group=shift(@{$self->{'LIST'}}); | |||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | 0 | return ($member,$group); | |||||||||||||||||||
| 41 | } | ||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | 0 | ▶ | sub rows { | ||||||||||||||||||
|
Subroutine
rows: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 44 | 0 | my $self=shift; | |||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | 0 | return $self->{'COUNT'}; | |||||||||||||||||||
| 47 | } | ||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | =head1 NAME | ||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | Set::NestedGroup::Member - Set of nested groups | ||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | =head1 SYNOPSIS | ||||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | use Set::NestedGroup; | ||||||||||||||||||||
| 57 | $acl = new Set::NestedGroup; | ||||||||||||||||||||
| 58 | $acl->add('user','group'); | ||||||||||||||||||||
| 59 | $acl->add('group','parentgroup'); | ||||||||||||||||||||
| 60 | $list=$acl->list(); | ||||||||||||||||||||
| 61 | for(my $i=0;$i<$list->rows();$i++){ | ||||||||||||||||||||
| 62 | my ($member,$group)=$list->next(); | ||||||||||||||||||||
| 63 | print "$member=$group\n"; | ||||||||||||||||||||
| 64 | } | ||||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | =head1 DESCRIPTION | ||||||||||||||||||||
| 67 | |||||||||||||||||||||
| 68 | Set::NestedGroup::Member objects are returns from a Set::NestedGroup | ||||||||||||||||||||
| 69 | object's list() method. | ||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | =head1 METHODS | ||||||||||||||||||||
| 72 | |||||||||||||||||||||
| 73 | =item rows () | ||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | Returns the number of rows this has. May be used to construct a loop | ||||||||||||||||||||
| 76 | to extract all the data. | ||||||||||||||||||||
| 77 | |||||||||||||||||||||
| 78 | =item next () | ||||||||||||||||||||
| 79 | |||||||||||||||||||||
| 80 | Returns a list comprising of the next member & group. Returns undef | ||||||||||||||||||||
| 81 | when the list is exhausted. | ||||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | =head1 AUTHOR | ||||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | Alan R. Barclay, gorilla@elaine.drink.com | ||||||||||||||||||||
| 86 | |||||||||||||||||||||
| 87 | =head1 SEE ALSO | ||||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | perl(1), Set::NestedGroup | ||||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | =cut | ||||||||||||||||||||