Class: Vapor::PersistenceManager

Class Vapor::PersistenceManager |
In: | vapor/persistencemgr.rb
Parent: | Object

Central interface to the VAPOR framework. Manages Persistable objects.

Methods

autocommit= autocommit? autocommit_in_progress? each_loaded_object get_extent get_object get_object_version new next_oid query transaction

Included modules

Exceptions

Public Class methods

new( properties )

Initialize a new PersistenceManager.

`properties` is a `Hash`-like object responding to `[key]`. For unknown keys, it should return `nil`. Keys used by the PersistenceManager are:

`Vapor.Datastore.Username`: | Username used to authenticate connection to Datastore
`Vapor.Datastore.Password`: | Password used to authenticate connection to Datastore
`Vapor.Datastore.Name`: | Name of the Datastore
`Vapor.Datastore.Host`: | Hostname where the Datastore resides
`Vapor.Datastore.Port`: | optional, Port used to connect to host where Datastore resides
`Vapor.Autocommit`: | optionalIf Autocommmit-Mode should be set on startup. Defaults to `true` if unspecified. All values other then `false` or `nil` are treated as `true`.
`Vapor.Datastore.BackendClass`: | optional, `Class` used to access Datastore, defaults to `TupleManager`, don’t specify anything unless absolutely sure

Public Instance methods

transaction( ) {|transaction| ...}

Transaction instance asssociated with the PersistenceManager. When the optional block is given, pass it to Transaction#do. `PersistenceManager#transaction{|t| …}` is equivalent to `PersistenceManager#transaction.do{|t| …}`.

get_object( oid )

Returns the Persistable with the specific OID from the Repository.

get_object_version( klass, oid, revision )

Returns an archived version of a persistent object of the specified klass, oid and revision. The object’s satate is READONLY and thus non-modifiable. Returns nil if such an object (either the klass, the oid or the version ) can’t be found. The returned objects are not cached and two different objects are returned when the method is called twice with the same arguments.

get_extent( klass, subclasses = true )

Returns an Extent containing all instances of a the Persistable Class. If `subclasses` is `true`, the Extent will contain all instances of persistable subclasses of the Class.

next_oid()

Retursn an previouslyu unused, unique OID.

each_loaded_object() {|obj }| ...}

Iterator over all all persistent objects.

query( klass, query, arguments, subclasses = true )

Search for persistent objects of a specific class in the Repository. Returns an Extent containing the objects matching the query, empty if none match. Result will include instances of subclasses matching the query, too, if `subclasses` is `true`.

autocommit?()

Returns `true` if Autocommit-Mode is turned on.

autocommit=( value )

Set status of Autocommit-Mode. Flushes all previous changes when setting to `true`. All subsequent changes will be flushed immediatly.

autocommit_in_progress?()

Returns `true` if a microtransaction of an Autocommit is in progress.