Class: Turbo::Queue

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(queue_name) ⇒ Queue

Returns a new instance of Queue.



6
7
8
9
# File 'lib/turbo/queue.rb', line 6

def initialize(queue_name)
  self.name = queue_name
  self.queue = find_or_create(queue_name)
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/turbo/queue.rb', line 4

def name
  @name
end

#queueObject

Returns the value of attribute queue.



4
5
6
# File 'lib/turbo/queue.rb', line 4

def queue
  @queue
end

Instance Method Details

#messagesObject



15
16
17
18
19
20
21
# File 'lib/turbo/queue.rb', line 15

def messages
  all_messages = []
  self.queue.receive_messages.each do |message|
    all_messages << Turbo::Message.new(:with => message)
  end
  all_messages
end

#messages?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/turbo/queue.rb', line 23

def messages?
  self.queue.size == 0 ? false : true
end

#send(message) ⇒ Object



11
12
13
# File 'lib/turbo/queue.rb', line 11

def send(message)
  self.queue.send_message(message)
end