Yote::Obj - Base class for all persistant Yote objects.
Yote::Obj is the base class for all stateful Yote objects that have an API presence and will be stored in persistant.
This is a container class and all objects of this class have automatic getter and setter methods for scalar and list entries. Invoking '$yote_obj->set_foo( "bar" );' will cause a variable named 'foo' to be attached to this object and assigned the value of "bar". The values that can be assigend are any number, string, hash, list or Yote::Obj object. Calling 'my $val = $yote_obj->get_baz( "fred" )' will return the value of the variable 'baz', and if none is defined, assigns the value "fred" to 'baz' and returns it.
Additionally, '$yote_obj->add_to_foo( "a", "b", "c", "c" )' will add the values 'a', 'b', 'c' and 'c' to the list with the variable name 'foo' that is attached to this object. If no such variable exists, a list will be created and assigned to it. If there already is a 'foo' that is not a list, and error will not result. There are a counterpart methods '$yote_obj->remove_from_foo( "c" )' which removes the first instance of c from the foo list, and '$yote_obj->remove_all_from_foo( "b" )' which will remove all the "b" values from the 'foo' list.
All Yote objects except YoteRoot are attached to an application or descent of the Yote::AppRoot class.
public_api_method( $data, $account )
Where $data is either a scalar value, a list, hash or yote object. $account is the account assigned to the user for the app that this yote object belongs to. $account may be undefined if the method may be called by someone not logging in.
There are different method types for yote :
These methods are called automatically by the yote system and are not meant to be called by other subs. The yote system automatically passes data given to the API and passes in the account of the logged in user (if any), so the signature for these methods is always the same.
These are the methods that are automatic to any yote object. The 'foo', is of course, a stand in for any data name.
Yote has 3 behaviors for data fields of Yote objects
This takes a hash reference as an argument and uses the key/value entries in this hash to set values for the fields corresponding to the hash keys.
Returns true if the single object argument passed in is equivalent to this one.
This is called once : only the very first time a Yote object is created. It is used to set up initial data.
This method is called each time an object is loaded from the data store.
Returns the number of items for the field of this object provided it is an array or hash.
Returns a paginated list or hash. Arguments are
* name - name of data structure attached to this object. * search_fields - a list of fields to search for in collections of yote objects * search_terms - a list of terms to search for * sort_fields - a list of fields to sort by for collections of yote objects * reversed_orders - a list of true or false values corresponding to the sort_fields list. A true value means that field is sorted in reverse * limit - maximum number of entries to return * skip - skip this many entries before returning the list * return_hash - return the result as a hashtable rather than as a list * reverse - return the result in reverse order
This method is actually a no-op, but has the effect of syncing the state of client and server.
Copyright (C) 2011 Eric Wolf
This module is free software; it can be used under the same terms as perl itself.