Class: Aeternitas::StorageAdapter Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/aeternitas/storage_adapter.rb,
lib/aeternitas/storage_adapter/file.rb

Overview

This class is abstract.

Create a subclass and override #store, ##retrieve and ##delete to create a new storage adapter

Storage Adapters take care of handling source files.

Direct Known Subclasses

File

Defined Under Namespace

Classes: File

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ StorageAdapter

Create a new storage adapter



8
9
10
# File 'lib/aeternitas/storage_adapter.rb', line 8

def initialize(config)
  @config = config
end

Instance Method Details

#delete(id) ⇒ Boolean

This method is abstract.

Delete the entry with the given fingerprint

Raises:

  • (NotImplementedError)


32
33
34
# File 'lib/aeternitas/storage_adapter.rb', line 32

def delete(id)
  raise NotImplementedError, "#{self.class.name} does not implement #delete, required by Aeternitas::StorageAdapter"
end

#exist?(id) ⇒ Boolean

This method is abstract.

Checks whether the entry with the given fingerprint exists.

Raises:

  • (NotImplementedError)


40
41
42
# File 'lib/aeternitas/storage_adapter.rb', line 40

def exist?(id)
  raise NotImplementedError, "#{self.class.name} does not implement #exist?, required by Aeternitas::StorageAdapter"
end

#retrieve(id) ⇒ String

This method is abstract.

Retrieves the content of the entry with the given fingerprint

Raises:

  • (NotImplementedError)


24
25
26
# File 'lib/aeternitas/storage_adapter.rb', line 24

def retrieve(id)
  raise NotImplementedError, "#{self.class.name} does not implement #retrive, required by Aeternitas::StorageAdapter"
end

#store(id, raw_content) ⇒ Object

This method is abstract.

Store a new entry with the given id and raw content

Raises:

  • (NotImplementedError)


16
17
18
# File 'lib/aeternitas/storage_adapter.rb', line 16

def store(id, raw_content)
  raise NotImplementedError, "#{self.class.name} does not implement #store, required by Aeternitas::StorageAdapter"
end