TABOO/Data/Plurals/Users.pm untested

filter: Statementstmt 0.0% 0 / 50 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 71 CC 2 SCAR 9.6
CC
2
Cov
0%
load
6.0
new
2.0
BEGIN
2.0
CRAP 2.6
1 package AxKit::App::TABOO::Data::Plurals::Users;
2 use strict;
3 use warnings;
4 use Carp;
5  
6 use Data::Dumper;
7 use AxKit::App::TABOO::Data;
8 use AxKit::App::TABOO::Data::User;
9 use AxKit::App::TABOO::Data::Plurals;
10  
11  
12 use vars qw/@ISA/;
13 @ISA = qw(AxKit::App::TABOO::Data::Plurals);
14  
15 use DBI;
16 use Exception::Class::DBI;
17  
18  
19 our $VERSION = '0.19';
20  
21 AxKit::App::TABOO::Data::Plurals::Users->dbtable("users");
22 AxKit::App::TABOO::Data::Plurals::Users->dbfrom("users");
23  
24  
25 =head1 NAME
26  
27 AxKit::App::TABOO::Data::Plurals::Users - Data objects to handle multiple Users in TABOO
28  
29 =head1 DESCRIPTION
30  
31 Often, you want to retrieve many different users from the data store,
32 for example all with certain privileges. This is a typical situation
33 where this class shoule be used.
34  
35 =head2 Methods
36  
37 =over
38  
39 =item C<new(@dbconnectargs)>
40  
41 The constructor. Nothing special.
42  
43 =cut
44  
45 sub new {
46 my $that = shift;
47 my $class = ref($that) || $that;
48 my $self = {
49 ENTRIES => [], # Internally, some methods finds it useful that the entries are stored in a array of this name.
50 DBCONNECTARGS => \@_,
51 XMLPREFIX => undef,
52 XMLELEMENT => undef,
53 XMLNS => undef,
54 };
55 bless($self, $class);
56 return $self;
57 }
58  
59  
60 =item C<load(what =E<gt> fields, limit =E<gt> {key =E<gt> value, [...]}, orderby =E<gt> fields, entries =E<gt> number)>
61  
62 This load method can be used to retrieve a number of entries from a
63 data store. It uses named parameters, the first C<what> is used to
64 determine which fields to retrieve. It is a string consisting of a
65 commaseparated list of fields, as specified in the data store. The
66 C<limit> argument is to be used to determine which records to
67 retrieve, these will be combined by logical AND. You may also supply a
68 C<orderby> argument, which is an expression used to determine the
69 order of entries returned. Finally, you may supply a C<entries>
70 argument, which is the maximum number of entries to retrieve.
71  
72 It will retrieve the data, and then call C<populate()> for each of the
73 records retrieved to ensure that the plural data objects actually
74 consists of an array of L<AxKit::App::TABOO::Data::User>s. But it
75 calls the internal C<_load()>-method to do the hard work (and that's
76 in the parent class).
77  
78 If there is no data that corresponds to the given arguments, this
79 method will return C<undef>.
80  
81 =cut
82  
83  
84 sub load {
85 my ($self, %args) = @_;
86 my $data = $self->_load(%args); # Does the hard work
87 return undef unless (@{$data});
88 foreach my $entry (@{$data}) {
89 my $cat = AxKit::App::TABOO::Data::User->new($self->dbconnectargs());
90 $cat->populate($entry);
91 $cat->onfile;
92 $self->Push($cat);
93 }
94 return $self;
95 }
96  
97 =back
98  
99 =head1 BUGS/TODO
100  
101 This is really not very well tested, it gets the users, but probably
102 not all the information from subclasses of the singular objects.
103  
104  
105 =head1 FORMALITIES
106  
107 See L<AxKit::App::TABOO>.
108  
109 =cut
110  
111 1;
112  
113