Class: KarlMalone::ConsumerOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/karl_malone/consumer_options.rb

Constant Summary collapse

EXCHANGE_TYPES =
[:direct, :fanout, :topic, :headers]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(exchange_options, queue_options) ⇒ ConsumerOptions

Returns a new instance of ConsumerOptions.



6
7
8
9
10
11
# File 'lib/karl_malone/consumer_options.rb', line 6

def initialize(exchange_options, queue_options)
  @exchange_options = exchange_options
  @queue_options    = queue_options
  validate_exchange_options!
  validate_queue_options!
end

Instance Attribute Details

#exchange_optionsObject (readonly)

Returns the value of attribute exchange_options.



4
5
6
# File 'lib/karl_malone/consumer_options.rb', line 4

def exchange_options
  @exchange_options
end

#queue_optionsObject (readonly)

Returns the value of attribute queue_options.



4
5
6
# File 'lib/karl_malone/consumer_options.rb', line 4

def queue_options
  @queue_options
end

Instance Method Details

#exchange_configurationsObject



29
30
31
32
33
34
35
36
37
38
# File 'lib/karl_malone/consumer_options.rb', line 29

def exchange_configurations
  {
    :passive             => false,
    :durable             => false,
    :auto_delete         => false,
    :internal            => false,
    :default_routing_key => nil,
    :no_declare          => true
  }.merge(exchange_options)
end

#exchange_nameObject



17
18
19
# File 'lib/karl_malone/consumer_options.rb', line 17

def exchange_name
  exchange_options[:name]
end

#exchange_typeObject



13
14
15
# File 'lib/karl_malone/consumer_options.rb', line 13

def exchange_type
  exchange_options[:type]
end

#queue_configurationsObject



40
41
42
43
44
45
46
47
48
# File 'lib/karl_malone/consumer_options.rb', line 40

def queue_configurations
  {
    :passive     => false,
    :durable     => false,
    :exclusive   => false,
    :auto_delete => false,
    :no_wait     => false
  }.merge(queue_options)
end

#queue_nameObject



21
22
23
# File 'lib/karl_malone/consumer_options.rb', line 21

def queue_name
  queue_options[:name]
end

#routing_keyObject



25
26
27
# File 'lib/karl_malone/consumer_options.rb', line 25

def routing_key
  queue_options[:routing_key]
end