Sha256: 5f4fed587b6da28abd375e94ebd66e6010634a9a4cabe278190cdf6dcc4fcd6f

Contents?: true

Size: 895 Bytes

Versions: 2

Compression:

Stored size: 895 Bytes

Contents

require_relative 'drama_queen/version'


# This is the singleton that maintains the list of active exchanges.
module DramaQueen

  # The list of all exchanges that DramaQueen knows about.  This is updated
  # by DramaQueen::Consumers as they subscribe to topics.
  #
  # @return [Array<DramaQueen::Exchange>]
  def self.exchanges
    @exchanges ||= Array.new
  end

  # Finds the DramaQueen::Exchange for the given +routing_key+.
  #
  # @param [Object] routing_key
  # @return [DramaQueen::Exchange]
  def self.exchange_for(routing_key)
    exchanges.find do |exchange|
      exchange.routing_key == routing_key
    end
  end

  # @param [Object] routing_key
  # @return [Boolean]
  def self.routes_to?(routing_key)
    !!exchange_for(routing_key)
  end

  # Removes all exchanges from the exchanges list.
  #
  # @return [Array]
  def self.unsubscribe_all
    @exchanges = Array.new
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
drama_queen-0.1.1 lib/drama_queen.rb
drama_queen-0.1.0 lib/drama_queen.rb