File Coverage

blib/lib/Set/NestedGroups/Member.pm
Criterion Covered Total %
statement 6 27 22.2
branch n/a
condition 0 3 0.0
subroutine 2 6 33.3
pod n/a
total 8 36 22.2


line stmt bran cond sub pod time code
1             package Set::NestedGroups::MemberList;
2              
3 1     1   8 use strict;
  1         2  
  1         31  
4 1     1   5 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
  1         2  
  1         304  
5              
6             @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             @EXPORT = qw(
11            
12             );
13             $VERSION = '0.01';
14              
15             # Preloaded methods go here.
16              
17             sub new {
18 0     0     my $proto=shift;
19 0   0       my $class=ref($proto) || $proto;
20 0           my $self ={};
21 0           $self->{'COUNT'}= 0;
22 0           bless($self,$class);
23 0           return $self;
24             }
25              
26             sub add {
27 0     0     my $self=shift;
28 0           my ($member,$group)=@_;
29 0           push(@{$self->{'LIST'}},$member);
  0            
30 0           push(@{$self->{'LIST'}},$group);
  0            
31 0           $self->{'COUNT'}++;
32             }
33              
34             sub next {
35 0     0     my $self=shift;
36              
37 0           my $member=shift(@{$self->{'LIST'}});
  0            
38 0           my $group=shift(@{$self->{'LIST'}});
  0            
39              
40 0           return ($member,$group);
41             }
42              
43             sub rows {
44 0     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