NAME
Class::Persist::Base - base class for all Class::Persist objects
DESCRIPTION
This base class implements features common to all Class::Persist objects - the accessors creation methods,
OBJECT CREATION
new( key => value, key => value, ... )
new creates and returns a new object. Any parameters are passed to the init method.
init
the init method is called by new() after it creates an object. The init assumes the passed parameters are a hash, takes the keys, and calls the methods with the names of the keys, passing the values. The common use for this is to pass initial values for all the accessor methods when calling new():
my $object = Your::Subclass->new( foo => 'bar' );
override the init method in your subclass if you need to perform setup, but remember to call the init method of the superclass first, and return undef if it fails:
sub init {
my $self = shift;
$self->SUPER::init(@_) or return;
...
return 1;
}
Return 1 to indicate your init was successful, and the new method will return the object. Returning a false value will cause new() to fail.
METHODS
oid
A UUID that uniquely identifies this object in the world. It would be bad to change this unless you know what you are doing. It's probably bad even if you do know what you're doing.
mk_accessors
get( column )
set( column => value, [ column => value ... ] )
NAME
Class::Persist::Base - Base class for Class::Persist
DESCRIPTION
This is a useful thing to inherit from - it gives you accessors, a new / init method that will initialise the object, emit/throw/record methods for throwing errors, and does the right thing when accessors don't return true values.