Objects::Collection - abstract class for collections of data.
use Objects::Collection; @Objects::Collection::AutoSQL::ISA = qw(Objects::Collection);
A collection - sometimes called a container - is simply an object that groups multiple elements into a single unit. Collections are used to store, retrieve, manipulate, and communicate aggregate data.
Method for store changed objects. Called with ref to hash :
{ ID1 => <reference to object1> [,ID2 => <reference to object2>,...] }
Read data for given IDs. Must return reference to hash, where keys is IDs, values is readed data. For example:
return {1=>[1..3],2=>[5..6]}
Create recods in data storage.
Parametrs:
user defined format
Result: Must return reference to hash, where keys is IDs, values is create records of data
Delete records in data storage for given IDs.
Parametrs: array id IDs
ID1, ID2, ...
or array of refs to HASHes
{ id=>ID1 }, {id => ID2 }, ...
Format of parametrs depend method delete_objects
Called before insert readed objects into collection. Must return ref to data or object, which will insert to callection.
Public method for create objects.
Public method. Fetch object from collection for given ID. Return ref to objects or undef unless exists.
Public method. Fetch objects from collection for given IDs. Return ref to HASH, where where keys is IDs, values is objects refs.
Release from collection objects with IDs.
Call _store for changed objects. Store all all loaded objects without parameters:
$simple_collection->store_changed(); #store all changed
or (for 1,2,6 IDs )
$simple_collection->store_changed(1,2,6);
Release from collections and delete from storage (by calling _delete) objects ID1,ID2...
$simple_collection->delete_objects(1,5,84);
Method for base support lazy load objects from data storage. Not really return lazy object.
Objects::Collection::AutoSQL, README
Zahatski Aliaksandr, <zag@cpan.org>
Copyright (C) 2005-2006 by Zahatski Aliaksandr
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.
To install Objects::Collection, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Objects::Collection
CPAN shell
perl -MCPAN -e shell install Objects::Collection
For more information on module installation, please visit the detailed CPAN module installation guide.