Sha256: 657dfc4486403fb5d287ed9d2fa279472e607dc07bbc24da92a0d203326eb468

Contents?: true

Size: 673 Bytes

Versions: 15

Compression:

Stored size: 673 Bytes

Contents

module QueueBus
  class Dispatchers
    def dispatch(app_key=nil, &block)
      dispatcher = dispatcher_by_key(app_key)
      dispatcher.instance_eval(&block)
      dispatcher
    end
    
    def dispatchers
      @dispatchers ||= {}
      @dispatchers.values
    end
    
    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
    
    def dispatcher_execute(app_key, key, attributes)
      @dispatchers ||= {}
      dispatcher = @dispatchers[app_key]
      dispatcher.execute(key, attributes) if dispatcher
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
queue-bus-0.9.0 lib/queue_bus/dispatchers.rb
queue-bus-0.8.1 lib/queue_bus/dispatchers.rb
queue-bus-0.8.0 lib/queue_bus/dispatchers.rb
queue-bus-0.7.0 lib/queue_bus/dispatchers.rb
queue-bus-0.6.0 lib/queue_bus/dispatchers.rb
queue-bus-0.5.9 lib/queue_bus/dispatchers.rb
queue-bus-0.5.8 lib/queue_bus/dispatchers.rb
queue-bus-0.5.7 lib/queue_bus/dispatchers.rb
queue-bus-0.5.6 lib/queue_bus/dispatchers.rb
queue-bus-0.5.5 lib/queue_bus/dispatchers.rb
queue-bus-0.5.4 lib/queue_bus/dispatchers.rb
queue-bus-0.5.3 lib/queue_bus/dispatchers.rb
queue-bus-0.5.2 lib/queue_bus/dispatchers.rb
queue-bus-0.5.1 lib/queue_bus/dispatchers.rb
queue-bus-0.5.0 lib/queue_bus/dispatchers.rb