File Coverage

blib/lib/E2/Usergroup.pm
Criterion Covered Total %
statement 31 49 63.2
branch 3 16 18.7
condition 1 3 33.3
subroutine 9 15 60.0
pod 5 7 71.4
total 49 90 54.4


line stmt bran cond sub pod time code
1             # E2::Usergroup
2             # Jose M. Weeks
3             # 05 June 2003
4             #
5             # See bottom for pod documentation.
6              
7             package E2::Usergroup;
8              
9 2     2   33764 use 5.006;
  2         6  
  2         75  
10 2     2   12 use strict;
  2         3  
  2         57  
11 2     2   10 use warnings;
  2         3  
  2         50  
12 2     2   9 use Carp;
  2         3  
  2         186  
13              
14 2     2   587 use E2::Node;
  2         6  
  2         1833  
15              
16             our @ISA = "E2::Node";
17             our $VERSION = "0.32";
18             our $DEBUG; *DEBUG = *E2::Interface::DEBUG;
19              
20             # Prototypes
21              
22             sub new;
23             sub clear;
24              
25             sub description;
26             sub list_members;
27             sub list_weblog;
28              
29             # Private
30              
31             sub type_as_string;
32             sub twig_handlers;
33              
34             # Object Methods
35              
36             sub new {
37 1     1 1 102 my $arg = shift;
38 1   33     8 my $class = ref( $arg ) || $arg;
39 1         19 my $self = $class->SUPER::new();
40              
41             # See clear for the other members of $self
42              
43 1         3 $self->clear;
44 1         3 return $self;
45             }
46              
47             sub clear {
48 3 50   3 1 16 my $self = shift or croak "Usage: clear E2USERGROUP";
49              
50 3 50       6 warn "E2::Usergroup::clear\n" if $DEBUG > 1;
51            
52 3         5 @{ $self->{members} } = ();
  3         7  
53 3         3 @{ $self->{weblog} } = ();
  3         6  
54 3         5 $self->{description} = undef;
55              
56             # Now clear parent
57              
58 3         14 return $self->SUPER::clear;
59             }
60              
61             sub twig_handlers {
62 1 50   1 0 5 my $self = shift or croak "Usage: twig_handlers E2USERGROUP";
63              
64             return (
65             'description' => sub {
66 0     0   0 (my $a, my $b) = @_;
67 0         0 $self->{description} = $b->text;
68             },
69             'weblog/e2link' => sub {
70 0     0   0 (my $a, my $b) = @_;
71 0         0 push @{ $self->{weblog} }, {
  0         0  
72             title => $b->text,
73             id => $b->{att}->{node_id}
74             };
75             },
76             'usergroup/e2link' => sub {
77 0     0   0 (my $a, my $b) = @_;
78 0         0 push @{ $self->{members} }, {
  0         0  
79             name => $b->text,
80             id => $b->{att}->{node_id}
81             };
82             }
83 1         24 );
84             }
85              
86             sub type_as_string {
87 1     1 0 8 return 'usergroup';
88             }
89              
90             sub description {
91 0 0   0 1   my $self = shift or croak "Usage: description E2USERGROUP";
92 0           return $self->{description};
93             }
94              
95             sub list_members {
96 0 0   0 1   my $self = shift or croak "Usage: list_members E2USERGROUP";
97 0 0         return undef if !$self->node_id;
98 0           return @{ $self->{members} };
  0            
99             }
100              
101             sub list_weblog {
102 0 0   0 1   my $self = shift or croak "Usage: list_weblog E2USERGROUP";
103 0 0         return undef if !$self->node_id;
104 0           return @{ $self->{weblog} };
  0            
105             }
106              
107             1;
108             __END__