Class: RightPublish::StorageManager

Inherits:
Object
  • Object
show all
Defined in:
lib/right_publish/storage.rb

Constant Summary collapse

@@storage_type_regex =
/\A(\w+)_storage/
@@storage_table =
{}

Class Method Summary collapse

Class Method Details

.get_storage(type) ⇒ Object



9
10
11
# File 'lib/right_publish/storage.rb', line 9

def self.get_storage(type)
  @@storage_table[type] if @@storage_table[type]
end

.register_storage(module_type) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/right_publish/storage.rb', line 19

def self.register_storage(module_type)
  storage_key = module_type::STORAGE_KEY

  if module_type.respond_to?(:get_directories) && @@storage_type_regex.match(storage_key.to_s)
   @@storage_table[storage_key] = module_type
   RightPublish::Profile.instance.register_section(@@storage_type_regex.match(storage_key.to_s)[1], module_type::STORAGE_OPTIONS)
  else
    raise TypeError
  end
  nil
end

.storage_typesObject



13
14
15
16
17
# File 'lib/right_publish/storage.rb', line 13

def self.storage_types()
  type_hash = {}
  @@storage_table.each_key { |k| type_hash[@@storage_type_regex.match(k.to_s)[1]] = k }
  type_hash
end