Class: Vapor::RepositoryManager

Class Vapor::RepositoryManager |
In: | vapor/repositorymgr.rb
Parent: | Object

Manager for metadata of an VAPOR Repository. Can add new classes or initialize a fresh Repository.

Methods

addclass class_known? commit_transaction get_class_attributes init_repository new removeclass start_transaction updateclass

Included modules

Exceptions

Public Class methods

new( db_spec, user, pass, check_repository = true )

Create a Manager for the Repository at the Datastore specified in `db_spec`

`db_spec` is a `String` with fields separated by colons: "driver:database:host[:port]".

If `check_repository` is false, validity of Repository is not checked. Use when connecting to an uninitialized Repository.

Public Instance methods

init_repository()

Initialize the Datastore as a Repository. Raises BackendInconsistentError if the Datastore is not empty.

addclass( klass )

Register a new class’s metadata with the Repository. Takes a ClassMetaData as arugment.

Raises a DuplicateClassError if the class is already known to the Repository and a UnknownSuperclassError if the superclass is unknown. A BackendInconsistentError is raised if the Datastore has an error due to unknown reasons. Raises a InvalidMetadtaError if the class is trying to redefine a superclass’ attribute in a incompatible manner or an array attribute is part of an uniqueness constraint (PostgreSQL restriction)

class_known?( klass )

Returns `true` if a class with the given name is known to the Repository.

get_class_attributes( klass )

retrieve metadata about a class, Array of reference-attributes

start_transaction()

Begin an transaction to manipulate the Repository.

commit_transaction()

Commit running transaction, actually making changes to the Repository.

removeclass( klass, recursive )

Remove metadata of a class and all it’s instances. Will fail with a `ClassNotKnownError` if the class is not known. If the class has child classes it will fail with a `ClassNotDeletableError` unless `recursive` is set to `true`.

updateclass( new_klassdef )

Update metadata of a Persistable class that is already registered with the Repository. Raises a `ClassNotKnownError` if the class is not known to the Repository and a `InvalidMetadataError` with a explaining message on other errors.