module QueueingRabbit::Bus
Attributes
Public Class Methods
extended(othermod)
click to toggle source
# File lib/queueing_rabbit/bus.rb, line 4 def self.extended(othermod) othermod.extend(QueueingRabbit::InheritableClassVariables) othermod.class_eval do inheritable_variables :channel_options, :exchange_name, :exchange_options, :publishing_defaults end end
Public Instance Methods
batch_publishing?()
click to toggle source
# File lib/queueing_rabbit/bus.rb, line 54 def batch_publishing? !!@shared_exchange end
channel(options = {})
click to toggle source
# File lib/queueing_rabbit/bus.rb, line 15 def channel(options = {}) @channel_options ||= {} @channel_options.update(options) end
channel_options()
click to toggle source
# File lib/queueing_rabbit/bus.rb, line 20 def channel_options @channel_options ||= {} end
demand_batch_publishing!()
click to toggle source
# File lib/queueing_rabbit/bus.rb, line 48 def demand_batch_publishing! QueueingRabbit.follow_bus_requirements(self) do |_, exchange| @shared_exchange = exchange end end
exchange(*args)
click to toggle source
# File lib/queueing_rabbit/bus.rb, line 24 def exchange(*args) @exchange_options ||= {} name, options = extract_name_and_options(*args) @exchange_name = name if name @exchange_options.update(options) if options end
exchange_name()
click to toggle source
# File lib/queueing_rabbit/bus.rb, line 31 def exchange_name @exchange_name || '' end
exchange_options()
click to toggle source
# File lib/queueing_rabbit/bus.rb, line 35 def exchange_options @exchange_options || {} end
publish(payload, options = {}, method = :publish)
click to toggle source
# File lib/queueing_rabbit/bus.rb, line 58 def publish(payload, options = {}, method = :publish) args = [payload, publishing_defaults.merge(options)] if batch_publishing? QueueingRabbit.publish_to_exchange(@shared_exchange, *args) else QueueingRabbit.send(method, self, *args) end end
publish_with(options = {})
click to toggle source
# File lib/queueing_rabbit/bus.rb, line 39 def publish_with(options = {}) @publishing_defaults ||= {} @publishing_defaults.update(options) end
publishing_defaults()
click to toggle source
# File lib/queueing_rabbit/bus.rb, line 44 def publishing_defaults @publishing_defaults || {} end
Protected Instance Methods
extract_name_and_options(*args)
click to toggle source
# File lib/queueing_rabbit/bus.rb, line 70 def extract_name_and_options(*args) name = options = nil if args.first.kind_of?(Hash) options = args.first elsif args.count > 1 name, options = args else name = args.first end [name, options] end