Sha256: 4b2ea044d2f9ef951ed5e0a1b5bbe6ca45875bc0f961a0447ac4f675a8a1285b

Contents?: true

Size: 508 Bytes

Versions: 7

Compression:

Stored size: 508 Bytes

Contents

# frozen_string_literal: true

module CottonTail
  module DSL
    # Topic DSL
    class Topic
      def initialize(routing_prefix, context)
        @routing_prefix = routing_prefix
        @context = context
      end

      def handle(routing_suffix, handler = nil, &block)
        key = routing_key(routing_suffix)
        @context.instance_eval { handle key, handler, &block }
      end

      private

      def routing_key(suffix)
        [@routing_prefix, suffix].join('.')
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
cotton-tail-0.7.0 lib/cotton_tail/dsl/topic.rb
cotton-tail-0.6.1 lib/cotton_tail/dsl/topic.rb
cotton-tail-0.6.0 lib/cotton_tail/dsl/topic.rb
cotton-tail-0.5.0 lib/cotton_tail/dsl/topic.rb
cotton-tail-0.4.1 lib/cotton_tail/dsl/topic.rb
cotton-tail-0.4.0 lib/cotton_tail/dsl/topic.rb
cotton-tail-0.3.0 lib/cotton_tail/dsl/topic.rb