class Smith::Messaging::AmqpOptions
Attributes
routing_key[RW]
Public Class Methods
new(options={})
click to toggle source
# File lib/smith/messaging/amqp_options.rb, line 8 def initialize(options={}) @options = options @options_map = {:strict => {:immediate => true, :mandatory => true}} end
Public Instance Methods
exchange(*extra_opts)
click to toggle source
# File lib/smith/messaging/amqp_options.rb, line 13 def exchange(*extra_opts) merge(Smith.config.amqp.exchange.to_hash, @options, extra_opts) end
pop(*extra_opts)
click to toggle source
# File lib/smith/messaging/amqp_options.rb, line 21 def pop(*extra_opts) merge(Smith.config.amqp.pop.to_hash, @options, extra_opts) end
publish(*extra_opts)
click to toggle source
# File lib/smith/messaging/amqp_options.rb, line 25 def publish(*extra_opts) merge(Smith.config.amqp.publish.to_hash, {:routing_key => routing_key, :persistent => true}, extra_opts) end
queue(*extra_opts)
click to toggle source
# File lib/smith/messaging/amqp_options.rb, line 17 def queue(*extra_opts) merge(Smith.config.amqp.queue.to_hash, @options, extra_opts) end
subscribe(*extra_opts)
click to toggle source
# File lib/smith/messaging/amqp_options.rb, line 29 def subscribe(*extra_opts) merge(Smith.config.amqp.subscribe.to_hash, extra_opts) end
Private Instance Methods
expand_options(opts)
click to toggle source
# File lib/smith/messaging/amqp_options.rb, line 35 def expand_options(opts) options = opts.inject({}) do |a,(k,v)| a.tap do |acc| if @options_map.key?(k) acc.merge!(@options_map[k]) else acc[k] = v end end end end
merge(*hashes)
click to toggle source
# File lib/smith/messaging/amqp_options.rb, line 47 def merge(*hashes) hashes.flatten.inject({}) do |acc,h| acc.merge!(expand_options(h)) end end