Class: QueueBus::Dispatchers
- Inherits:
-
Object
- Object
- QueueBus::Dispatchers
- Defined in:
- lib/queue_bus/dispatchers.rb
Instance Method Summary collapse
- #dispatch(app_key = nil, &block) ⇒ Object
- #dispatcher_by_key(app_key) ⇒ Object
- #dispatcher_execute(app_key, key, attributes) ⇒ Object
- #dispatchers ⇒ Object
Instance Method Details
#dispatch(app_key = nil, &block) ⇒ Object
3 4 5 6 7 |
# File 'lib/queue_bus/dispatchers.rb', line 3 def dispatch(app_key=nil, &block) dispatcher = dispatcher_by_key(app_key) dispatcher.instance_eval(&block) dispatcher end |
#dispatcher_by_key(app_key) ⇒ Object
14 15 16 17 18 |
# File 'lib/queue_bus/dispatchers.rb', line 14 def dispatcher_by_key(app_key) app_key = Application.normalize(app_key || ::QueueBus.default_app_key) @dispatchers ||= {} @dispatchers[app_key] ||= Dispatch.new(app_key) end |
#dispatcher_execute(app_key, key, attributes) ⇒ Object
20 21 22 23 24 |
# File 'lib/queue_bus/dispatchers.rb', line 20 def dispatcher_execute(app_key, key, attributes) @dispatchers ||= {} dispatcher = @dispatchers[app_key] dispatcher.execute(key, attributes) if dispatcher end |
#dispatchers ⇒ Object
9 10 11 12 |
# File 'lib/queue_bus/dispatchers.rb', line 9 def dispatchers @dispatchers ||= {} @dispatchers.values end |