Sha256: 072ad55088bbe3f6f8121904ce5654a609d4839ad91dee9e6a366d114c92cfa6

Contents?: true

Size: 610 Bytes

Versions: 6

Compression:

Stored size: 610 Bytes

Contents

# frozen_string_literal: true

module CottonTail
  module DSL
    # Queue DSL
    class Queue
      def initialize(name, queue, context)
        @name = name
        @queue = queue
        @context = context
      end

      def handle(key, handler = nil, &block)
        bind(key)
        @context.handle(key, handler, &block)
      end

      def topic(routing_prefix, &block)
        topic = Topic.new(routing_prefix, self)
        topic.instance_eval(&block)
      end

      private

      def bind(key)
        return unless @queue.respond_to?(:bind)

        @queue.bind key
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
cotton-tail-0.4.0 lib/cotton_tail/dsl/queue.rb
cotton-tail-0.3.0 lib/cotton_tail/dsl/queue.rb
cotton-tail-0.2.1 lib/cotton_tail/dsl/queue.rb
cotton-tail-0.2.0 lib/cotton_tail/dsl/queue.rb
cotton-tail-0.1.2 lib/cotton_tail/dsl/queue.rb
cotton-tail-0.1.1 lib/cotton_tail/dsl/queue.rb