Class: VCSToolkit::ObjectStore
- Inherits:
-
Object
- Object
- VCSToolkit::ObjectStore
- 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
-
#each ⇒ Object
Implement this to enumerate over all objects that have Object#named? set to true.
-
#fetch(object_id) ⇒ Object
Implement this to retrieve an object with the specified object_id.
-
#key?(object_id) ⇒ Boolean
Implement this to detect wether a object with that object_id exists.
-
#store(object_id, object) ⇒ Object
Implement this to store a specific object in persistent storage.
Instance Method Details
#each ⇒ Object
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.
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).
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.
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
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 |