Module: Vapor::Persistable

Module Vapor::Persistable |
In: | vapor/persistable.rb

Mix-in providing classses with the ability to be persistently stored in a VAPOR Repository. Metadata about the class must be registered with the Repository before actual objects can be made persistent.

Methods

delete_persistent get_version make_persistent mark_dirty oid old_revision persistent? persistent_readonly? refresh_persistent revision state vapor_changelog

Included modules

Exceptions

Public Instance methods

persistent?()

Returns `true` if the object is stored in the Repository and has not changed after being synched with the Repository.

persistent_readonly?()

Returns `true` if the object’s state is READONLY. Normally, objects in this state are of archive copys of older revisions.

state()

Returns `String` containing current persistence status.

oid()

Object-ID, `nil` if object is transient

revision()

Revision number of the object. Starts with `0` when the object is initially made persistent and is increased by one, each time changes to it are committed. Returns `nil` if the object is transient.

vapor_changelog()

TransactionLog object that describes the transaction that made the last changes to the object, creating the current version of it.

make_persistent()

Make an transient object persistent. Raises an ObjectAlreadyPersistentError if the object is not transient and a RepositoryOfflineError if no PersistenceManager has been instantiated.

delete_persistent()

Mark an object to be deleted from the repository. The object will still exist in memory; it is only ‘detached’ from the repository, losing it’s persistent identitiy (OID) when the transaction is flushed. Does nothing if the object is TRANSIENT.

mark_dirty()

Mark an object as dirty. It will be saved when the transaction commits, which might be instantly if Auto-Commit mode is set. Call this method when the value of an persistent attribute has changed, preferably from setters. Does nothing if the object is TRANSIENT.

refresh_persistent()

Refresh values of object’s persistent attributes to current values in Datastore, setting the object’s state to PERSISTENT. Transient attributes are not touched. Does nothing if the object is transient or new. Raises a DeletedObjectError if the object can not be found in the Datastore. Does nothing if the object is TRANSIENT.

get_version( revision_number )

Retrieve an persistently archived version of self. Returns <code>nil</code> if a version with said revision mumber does not exist or the object is not persistent. The returned object is an Persistable in the state READONLY.

This method is also aliased as old_revision

old_revision( revision_number )

Alias for get_version