lib/bunny_mock/exchange.rb in bunny-mock-1.2.0 vs lib/bunny_mock/exchange.rb in bunny-mock-1.2.1

- old
+ new

@@ -1,34 +1,37 @@ # frozen_string_literal: true module BunnyMock class Exchange - ## - # Create a new {BunnyMock::Exchange} instance - # - # @param [BunnyMock::Channel] channel Channel this exchange will use - # @param [String] name Name of exchange - # @param [Hash] opts Creation options - # - # @option opts [Boolean] :durable (false) Should this exchange be durable? - # @option opts [Boolean] :auto_delete (false) Should this exchange be automatically deleted when it is no longer used? - # @option opts [Boolean] :arguments ({}) Additional optional arguments (typically used by RabbitMQ extensions and plugins) - # - # @return [BunnyMock::Exchange] A new exchange - # @see BunnyMock::Channel#exchange - # @api public - # - def self.declare(channel, name = '', opts = {}) + class << self - # get requested type - type = opts.fetch :type, :direct + ## + # Create a new {BunnyMock::Exchange} instance + # + # @param [BunnyMock::Channel] channel Channel this exchange will use + # @param [String] name Name of exchange + # @param [Hash] opts Creation options + # + # @option opts [Boolean] :durable (false) Should this exchange be durable? + # @option opts [Boolean] :auto_delete (false) Should this exchange be automatically deleted when it is no longer used? + # @option opts [Boolean] :arguments ({}) Additional optional arguments (typically used by RabbitMQ extensions and plugins) + # + # @return [BunnyMock::Exchange] A new exchange + # @see BunnyMock::Channel#exchange + # @api public + # + def declare(channel, name = '', opts = {}) - # get needed class type - klazz = BunnyMock::Exchanges.const_get type.to_s.capitalize + # get requested type + type = opts.fetch :type, :direct - # create exchange of desired type - klazz.new channel, name, type, opts + # get needed class type + klazz = BunnyMock::Exchanges.const_get type.to_s.capitalize + + # create exchange of desired type + klazz.new channel, name, type, opts + end end # # API # @@ -226,10 +229,14 @@ route = exchange_or_queue.respond_to?(:name) ? exchange_or_queue.name : exchange_or_queue @routes.key? opts.fetch(:routing_key, route) end - alias has_binding? routes_to? + + def has_binding?(exchange_or_queue, opts = {}) # rubocop:disable Style/PredicateName + warn '[DEPRECATED] `has_binding?` is deprecated. Please use `routes_to?` instead.' + routes_to?(exchange_or_queue, opts) + end ## # Deliver a message to routes # # @see {BunnyMock::Exchanges::Direct#deliver}