NAME

Haver::Savable - Framework for persistent objects.

SYNOPSIS

# See the source code for Haver::Config.

DESCRIPTION

Haver::Savable is a base class for objects that need to have persistency, such as config files. Haver::Savable is only a base class, you need to inherit from it in order to use it.

METHODS

new()

the new() constructor creates and returns a new Haver::Savable. It takes no options.

save()

This saves data to $self->filename(). It takes no arguments. The data to be saved is obtained by calling $self->_save_data(). =head2 load()

This loads data from $self->filename() and passes it to $self->_load_data().

auto_save($bool)

This gets or sets the auto_save option. If auto_save is true, then $self->save() will be called upon object destruction.

The default is false.

overwrite($bool)

This gets or sets the overwrite option. If overwrite is false, when you go to save() a savable object, it will cowardly refuse to overwrite $self->filename.

If overwrite is true, then it will always save over the file, even if the file has been modified since the last load().

The default is false.

VIRTUAL METHODS

These methods you must define in your subclasses (except for the optional one).

_init_data()

This is optional. If defined, it will be called when $self->filename() can not be found. It should probably set up default values that will later be saved to $self->filename().

_load_data($data)

This method should take whatever is in $data and load it into $self somehow. The type of $data is application-dependant; generally it is whatever $self->_save_data() returns (see below).

_save_data()

This method should inspect $self and return whatever should be written (serialized) to $self->filename().

SEE ALSO

https://gna.org/projects/haver/

AUTHOR

Dylan William Hardison, <dylanwh@tampabay.rr.com>

COPYRIGHT AND LICENSE

Copyright (C) 2004 by Dylan William Hardison

This library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this module; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA