Class: BugBunny::Queue

Inherits:
Object
  • Object
show all
Defined in:
lib/bug_bunny/queue.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Queue

Returns a new instance of Queue.



5
6
7
8
9
10
11
# File 'lib/bug_bunny/queue.rb', line 5

def initialize(attrs={})
  # "Real" queue  opts
  @name        = attrs.fetch(:name, 'undefined')
  @auto_delete = attrs.fetch(:auto_delete, true)
  @durable     = attrs.fetch(:durable, false)
  @exclusive   = attrs.fetch(:exclusive, false)
end

Instance Attribute Details

#auto_deleteObject

Returns the value of attribute auto_delete.



3
4
5
# File 'lib/bug_bunny/queue.rb', line 3

def auto_delete
  @auto_delete
end

#durableObject

Returns the value of attribute durable.



3
4
5
# File 'lib/bug_bunny/queue.rb', line 3

def durable
  @durable
end

#exclusiveObject

Returns the value of attribute exclusive.



3
4
5
# File 'lib/bug_bunny/queue.rb', line 3

def exclusive
  @exclusive
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/bug_bunny/queue.rb', line 3

def name
  @name
end

#rabbit_queueObject

Returns the value of attribute rabbit_queue.



3
4
5
# File 'lib/bug_bunny/queue.rb', line 3

def rabbit_queue
  @rabbit_queue
end

Instance Method Details

#check_consumersObject



17
18
19
20
21
# File 'lib/bug_bunny/queue.rb', line 17

def check_consumers
  rabbit_queue.consumer_count
rescue StandardError
  0
end

#optionsObject



13
14
15
# File 'lib/bug_bunny/queue.rb', line 13

def options
  { durable: durable, exclusive: exclusive, auto_delete: auto_delete }
end