The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Objects::Collection - abstract class for collections of data.

SYNOPSIS

    use Objects::Collection;
    @Objects::Collection::AutoSQL::ISA = qw(Objects::Collection);

DESCRIPTION

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.

METHODS

_store( {ID1 => <ref to object1>[, ID2 => <ref to object2>, ...]} )

Method for store changed objects. Called with ref to hash :

 {
    ID1 => <reference to object1>
    [,ID2 => <reference to object2>,...]
 }

_fetch({id=>ID1} [, {id=>ID2}, ...])

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(<user defined>)

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(ID1[, ID2, ...]) or ({ id=>ID1 } [, {id => ID2 }, ...])

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

_prepare_record( ID1, <reference to readed by _create record>)

Called before insert readed objects into collection. Must return ref to data or object, which will insert to callection.

create(<user defined>)

Public method for create objects.

fetch_object(ID1)

Public method. Fetch object from collection for given ID. Return ref to objects or undef unless exists.

fetch_objects(ID1 [, ID2, ...])

Public method. Fetch objects from collection for given IDs. Return ref to HASH, where where keys is IDs, values is objects refs.

Parametrs:

release_objects(ID1[, ID2, ...])

Release from collection objects with IDs.

store_changed([ID1,[ID2,...]])

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);

delete_objects(ID1[,ID2, ...])

Release from collections and delete from storage (by calling _delete) objects ID1,ID2...

    $simple_collection->delete_objects(1,5,84);

get_lazy_object(ID1)

Method for base support lazy load objects from data storage. Not really return lazy object.

SEE ALSO

Objects::Collection::AutoSQL, README

AUTHOR

Zahatski Aliaksandr, <zag@cpan.org>

COPYRIGHT AND LICENSE

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.