Class: Commandos::IAmACommandRegistry
- Inherits:
-
Object
- Object
- Commandos::IAmACommandRegistry
- Defined in:
- lib/commandos/registry.rb
Instance Method Summary collapse
- #[](command) ⇒ Object (also: #find_by)
-
#initialize(storage: DefaultStorageStrategy) ⇒ IAmACommandRegistry
constructor
A new instance of IAmACommandRegistry.
Constructor Details
#initialize(storage: DefaultStorageStrategy) ⇒ IAmACommandRegistry
Returns a new instance of IAmACommandRegistry.
3 4 5 |
# File 'lib/commandos/registry.rb', line 3 def initialize(storage: DefaultStorageStrategy) @storage = storage end |
Instance Method Details
#[](command) ⇒ Object Also known as: find_by
7 8 9 10 11 |
# File 'lib/commandos/registry.rb', line 7 def [](command) handlers.fetch(storage_strategy.call command) { NullHandler }.tap do |handler| yield handler if block_given? end end |