NAME

Fry::List - Base class serving as a container for its subclass's objects.

DESCRIPTION

This base class provides to its sub classes class methods for storing and accessing its objects. It also comes with a &new constructor which creates a hash-based object and stores it in the container or list.

Here are a few key points you should know:

- All objects must have a unique 'id' in the list.
- For now only one list of objects can be created per class.
This list is stored in &list. You must create a &list in the subclass
namespace to have a unique list. 
- One alias to an object's id is supported via an 'a' attribute in an
object. Use &findAlias to get the aliased id.
- Default values for required attributes can be set via
&_hash_default.They will only be made and set if the attribute isn't
defined.
- Warnings in this class can be turned on and off by the variable $Fry::List::Warn

PUBLIC METHODS

new(%attr_to_value): Given hash is blessed as an object after setting defaults. 
manyNew(%id_to_obj): Makes several objects.
manyNewScalar($attr,%id_to_value): Converts each hash value to a hash using $attr and
	&convertScalarToHash and then makes objects from modified hash.

Get and Set methods
	_obj($id,$object): Get and set an obj by id.
	Obj($id): Gets an obj if it exists, otherwise returns {}
	setObj(%id_to_obj): Set multiple objects with a hash of id to object pairs.
	getObj(@ids): Gets several objects by id.
	unloadObj(@ids): Unload/delete objects from list.
	get($id,$attr): Gets an attribute value of the object specified by id.
	set($id,$attr,$value): Sets an attribute value of the object specified by id.
	getMany($attr,@ids): Gets same attribute of several objects
	setMany($attr,%id_to_values): Sets same attribute of objects via a hash of object to attribute-value pairs.
	setOrMake(%id_to_values): If the object id exists then it passes the hash pair to
		&defaultSet, otherwise a new object is created via &defaultNew.

Other methods
	listIds(): Returns list of all object id's.
	listAlias (): Returns list of all aliases of all objects.
	listAliasAndIds (): Returns list of all aliases and all ids.
	findAlias($alias): Returns id that alias points to. Returns undef if no id found.
	anyAlias($alias): Wrapper around &findAlias which returns $alias instead.
	pushArray($id,$attr,@values): Pushes values onto array stored in object's attribute.
	objExists($id): Returns boolean indicating if object exists. Throws warning if it doesn't.
	attrExists($id): Returns boolean indicating if attribute exists.
	allAttr(): Returns all possible values of a given attribute for the class.
	findIds($attr,$comparison_type,$value): Returns all object of a class that whose
		attribute matches a value for a given comparison type. Possible comparison
		types are =,~,> and < .
	callSubAttr(%arg): Calls an attribute that is a subroutine. Attribute can be a
		coderef or the sub's name. This should be moved to Fry::Sub.

Subclassable subs
	defaultSet(): Method used to set a variable's values by &setOrMake, usually a
		wrapper around &setMany
	defaultNew(): Interface method used by subclasses to initialize a hash of objects.
	list: Returns a hash reference for holding all objects.
	_hash_default: Returns a hash reference with default attributes and values.

Utility subs
	setHashDefault($hash,($default_hash)?): Sets defaults to a hash, uses &_hash_default if
		no default hash given
	convertScalarToHash($hash,$key): Sets a hash value to a hashref of $key and its former value
	setId(%id_to_hash): Sets keys of arguments as ids of values which are hashes

AUTHOR

Me. Gabriel that is. I welcome feedback and bug reports to cldwalker AT chwhat DOT com . If you like using perl,linux,vim and databases to make your life easier (not lazier ;) check out my website at www.chwhat.com.

COPYRIGHT & LICENSE

Copyright (c) 2004, Gabriel Horner. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.