Class: VCSToolkit::ObjectStore

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/vcs_toolkit/object_store.rb

Overview

This class is used to implement a custom storage provider for objects.

The methods are compatible with the interface of Hash so that a simple Hash can be used instead of a full-featured object manager.

Instance Method Summary collapse

Instance Method Details

#eachObject

Implement this to enumerate over all objects that have Object#named? set to true. Even enumeration of all objects is possible, but is not neccessary.

The order of enumeration doesn’t matter.

Raises:

  • (NotImplementedError)


47
48
49
# File 'lib/vcs_toolkit/object_store.rb', line 47

def each
  raise NotImplementedError, 'You must implement ObjectStore#each'
end

#fetch(object_id) ⇒ Object

Implement this to retrieve an object with the specified object_id. It should detect the object type and instantiate the specific object class (or a subclass of it).

Raises:

  • (NotImplementedError)


28
29
30
# File 'lib/vcs_toolkit/object_store.rb', line 28

def fetch(object_id)
  raise NotImplementedError, 'You must implement ObjectStore#fetch'
end

#key?(object_id) ⇒ Boolean

Implement this to detect wether a object with that object_id exists.

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


35
36
37
# File 'lib/vcs_toolkit/object_store.rb', line 35

def key?(object_id)
  raise NotImplementedError, 'You must implement ObjectStore#key?'
end

#store(object_id, object) ⇒ Object

Implement this to store a specific object in persistent storage.

object_id is here for compatibility with Hash

Raises:

  • (NotImplementedError)


19
20
21
# File 'lib/vcs_toolkit/object_store.rb', line 19

def store(object_id, object)
  raise NotImplementedError, 'You must implement ObjectStore#store'
end