class Commandoes::IAmACommandRegistry
Public Class Methods
new(storage: DefaultStorageStrategy)
click to toggle source
# File lib/commandoes/registry.rb, line 3 def initialize(storage: DefaultStorageStrategy) @storage = storage end
Public Instance Methods
[](command) { |handler| ... }
click to toggle source
# File lib/commandoes/registry.rb, line 7 def [](command) handlers.fetch(storage_strategy.call command) { NullHandler }.tap do |handler| yield handler if block_given? end end
Also aliased as: find_by
Protected Instance Methods
handlers()
click to toggle source
# File lib/commandoes/registry.rb, line 17 def handlers @handlers ||= {} end
register(command, handler: nil)
click to toggle source
# File lib/commandoes/registry.rb, line 25 def register(command, handler: nil) unless handler.nil? handlers[storage_strategy.call command] = handler end end
storage_strategy()
click to toggle source
# File lib/commandoes/registry.rb, line 21 def storage_strategy @storage ||= DefaultStorageStrategy end