Class: Todoplicator::AdapterRegistry
- Inherits:
-
Object
- Object
- Todoplicator::AdapterRegistry
- Defined in:
- lib/todoplicator/adapter_registry.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add(key, klass) ⇒ Object
- #all ⇒ Object
- #for(key) ⇒ Object
-
#initialize ⇒ AdapterRegistry
constructor
A new instance of AdapterRegistry.
- #reset! ⇒ Object
Constructor Details
#initialize ⇒ AdapterRegistry
Returns a new instance of AdapterRegistry.
7 8 9 |
# File 'lib/todoplicator/adapter_registry.rb', line 7 def initialize reset! end |
Class Method Details
.instance ⇒ Object
3 4 5 |
# File 'lib/todoplicator/adapter_registry.rb', line 3 def self.instance @@instance ||= new end |
Instance Method Details
#add(key, klass) ⇒ Object
11 12 13 |
# File 'lib/todoplicator/adapter_registry.rb', line 11 def add(key, klass) @adapters[key.to_sym] = klass end |
#all ⇒ Object
19 20 21 |
# File 'lib/todoplicator/adapter_registry.rb', line 19 def all @adapters end |
#for(key) ⇒ Object
15 16 17 |
# File 'lib/todoplicator/adapter_registry.rb', line 15 def for(key) @adapters.fetch(key.to_sym) { raise UnknownAdapter, "#{key} not found" } end |
#reset! ⇒ Object
23 24 25 |
# File 'lib/todoplicator/adapter_registry.rb', line 23 def reset! @adapters = {} end |