NAME
AxKit::App::TABOO::Data::Plurals - Base class to handle multiple Data objects in TABOO
DESCRIPTION
Sometimes, it is desireable to retrieve and handle multiple instances of a data object, and most economic to do it in a single operation. That is what the Plural data objects are for. The load methods should generally retrieve all records as efficiently as they can, and then return an array of their singular counterparts.
METHODS
It implements some new methods, with names that should ring bells for everyone. It also reimplements some methods, but nothing you really need to be aware of, unless you want to implement a load
method for a subclass. If you want to raise your awareness anyway, the documentation of them is for you:
Push($singular)
-
This does pretty much what
push
does in a normal context, it adds a singular version$singular
of a object to the plural object that the method is used on. Grep($pattern, $field)
-
Somewhat similar to the usual
grep
function, but takes as argument a pattern to search for, but not enclosed in slashes, and which data field to look in. Will return an object of the same class with the records that matched, orundef
if there were no matches. _load(%args)
-
As the underscore implies this is for internal use only! It can do the hard work for subclasses of this class. It uses named parameters, the first
what
is used to determine which fields to retrieve. It is a string consisting of a commaseparated list of fields, as specified in the data store. If not given, all fields will be fetched. Thelimit
argument is to be used to determine which records to retrieve, these will be combined by logical AND. By default, exact matches of thelimit
arguments will be used, but you may also supply aregex
argument with an array containing the fields that should be fetched using case sensitive POSIX regular expressions.You may also supply a
orderby
argument, which is an expression used to determine the order of entries returned. Usually, it would be a simple string with the field name to use, e.g.'timestamp'
, but you might want to append the keyword "DESC
" to it for descending order. Finally, you may supply aentries
argument, which is the maximum number of entries to retrieve. It will return an arrayref containing the data from the storage. write_xml($doc, $parent)
-
To avoid bloating the parent class too much, this takes care of some specifics for plurals, but leaves most of the job to the parent class. Has a completely identical interface as the parent class, and can be called like it without further ado.
If an object of this class has had its element and/or namespace set with
xmlelement()
/xmlns()
/xmlprefix()
respectively, the individual entries will have the same element and/or namespace.
BUGS/TODO
The save method is not yet reimplemented and may not work.
FORMALITIES
See AxKit::App::TABOO.