Class: Bumbleworks::StorageAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/bumbleworks/storage_adapter.rb

Direct Known Subclasses

HashStorage

Defined Under Namespace

Classes: UnsupportedStorage

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.auto_registerObject

Returns the value of attribute auto_register.



5
6
7
# File 'lib/bumbleworks/storage_adapter.rb', line 5

def auto_register
  @auto_register
end

Class Method Details

.allow_history_storage?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/bumbleworks/storage_adapter.rb', line 37

def allow_history_storage?
  true
end

.auto_register?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/bumbleworks/storage_adapter.rb', line 7

def auto_register?
  auto_register.nil? || auto_register == true
end

.display_nameObject



33
34
35
# File 'lib/bumbleworks/storage_adapter.rb', line 33

def display_name
  storage_class.name
end

.driverObject



11
12
13
# File 'lib/bumbleworks/storage_adapter.rb', line 11

def driver
  raise "Subclass responsibility"
end

.new_storage(storage, options = {}) ⇒ Object

Raises:



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

def new_storage(storage, options = {})
  raise UnsupportedStorage unless use?(storage)
  wrap_storage_with_driver(storage, options)
end

.storage_classObject



29
30
31
# File 'lib/bumbleworks/storage_adapter.rb', line 29

def storage_class
  raise "Subclass responsibility"
end

.use?(storage) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/bumbleworks/storage_adapter.rb', line 25

def use?(storage)
  storage.is_a? storage_class
end

.wrap_storage_with_driver(storage, options = {}) ⇒ Object



20
21
22
23
# File 'lib/bumbleworks/storage_adapter.rb', line 20

def wrap_storage_with_driver(storage, options = {})
  # the base method ignores options; use them in subclasses
  driver.new(storage)
end