NAME
Class::Persist::Collection
SYNOPSIS
my $collection = Class::Persist::Collection->new();
$collection->owner($owner);
$collection->push($object1, $object2);
$collection->store();
$obj1 = $collection->[0];
DESCRIPTION
Class::Persist::Collection objects serve as the intermediate step between Class::Persist objects and their children in a has_many relationship. They can be deferenced as arrays, and will inflate their children from proxes as required.
INHERITANCE
Class::Persist::Base
METHODS
owner
A collection has an owner - this is the owner that all the members of the collection have.
element
When called for the first time, create an array of proxies representing the real objects. Returns a listref of the children of the collection.
load()
Replace all the element by proxies
store()
Store any non proxy element in the collection and proxy it
count()
returns the number of elements in the collection
push( element )
add an element to the end of the collection
unshift( element )
add an element to the beginning of the collection
delete( $index )
Without parameter, delete all the elements of the collection. If an index is given, deletes the related element.
Deletes elements recursively.
revert( [index] )
reverts either the given element (if index is passed) or all elements (if not).
clone( new_owner, [index] )
With an index, clones and returns the clone of the indexed element. Without, returns a Class::Persist::Collection that is a clone of itself, containing clones of all its elements.
new_owner is the object that will own the new collection, and must be passed.
SEE ALSO
Class::Persist