NAME
Data::ObjectDriver::BaseObject - base class for modeled objects
SYNOPSIS
See synopsis in Data::ObjectDriver.
DESCRIPTION
Data::ObjectDriver::BaseObject provides services to data objects modeled with the Data::ObjectDriver object relational mapper.
USAGE
Class->install_properties({ ... })
Sets up columns, indexes, primary keys, etc.
Class->properties
Returns the list of properties.
Class->has_a(ParentClass => { ... }, ParentClass2 => { ...} )
Creates utility methods that map this object to parent Data::ObjectDriver objects.
Pass in a list of parent classes to map with a hash of parameters. The following parameters are recognized:
column
Name of the column(s) in this class to map with. Pass in a single string if the column is a singular key, an array ref if this is a composite key.
column => 'user_id' column => ['user_id', 'photo_id']
method [OPTIONAL]
Name of the method to create in this class. Defaults to the column name(s) without the _id suffix and with the suffix _obj appended.
parent_method [OPTIONAL]
Name of the method created in the parent class. Default is the lowercased name of the current class with the suffix _objs.
cached [OPTIONAL]
If set to 1 cache the result of the fetching the parent object in the current class. Note that this is a private copy to this class only, and does not interact with other caches in the system.
column_func
This method is called to get/set column values. Subclasses can override this and get different behavior.
Class->driver
Returns the database driver for this class, invoking the class's get_driver function if necessary.
Class->get_driver($driver)
Sets the function used to find the object driver for Class objects.
$obj->primary_key
Returns the values of the primary key fields of $obj.
Class->primary_key_tuple
Returns the names of the primary key fields for objects of class Class.
$obj->has_primary_key
$obj->clone
Returns a new object of the same class as $obj containing the same data, except for primary keys, which are set to undef
.
$obj->clone_all
Returns a new object of the same class as $obj containing the same data, including all key fields.
$obj->deflate
Returns a minimal representation of the object, for use in caches where you might want to preserve space (like memcached). Can also be overridden by subclasses to store the optimal representation of an object in the cache. For example, if you have metadata attached to an object, you might want to store that in the cache, as well.
$class->inflate($deflated)
Inflates the deflated representation of the object $deflated into a proper object in the class $class.