Class: AppEngine::Labs::TaskQueue::Queue

Inherits:
Object
  • Object
show all
Defined in:
lib/appengine-apis/labs/taskqueue.rb

Overview

Represents a Queue.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil) ⇒ Queue

Returns the named Queue, or the default queue if name is nil.

The returned Queue object may not necessarily refer to an existing queue. Queues must be configured before they may be used. Attempting to use a non-existing queue name may result in errors at the point of use of the Queue object, not when creating it.



203
204
205
206
207
208
209
210
211
# File 'lib/appengine-apis/labs/taskqueue.rb', line 203

def initialize(name=nil)
  TaskQueue.convert_exceptions do
    if name.nil?
      @queue = QueueFactory.default_queue
    else
      @queue = QueueFactory.get_queue(name)
    end
  end
end

Class Method Details

.new(name = nil) ⇒ Object



213
214
215
# File 'lib/appengine-apis/labs/taskqueue.rb', line 213

def self.new(name=nil)
  @queues[name] ||= super
end

Instance Method Details

#add(task = nil) ⇒ Object

Submits a task to this queue.



218
219
220
221
222
223
224
225
226
# File 'lib/appengine-apis/labs/taskqueue.rb', line 218

def add(task=nil)
  if task.nil?
    Task.new.add(self)
  elsif task.java_kind_of? TaskOptions
    Task.new(task).add(self)
  else
    task.add(self)
  end
end

#java_queueObject



233
234
235
# File 'lib/appengine-apis/labs/taskqueue.rb', line 233

def java_queue
  @queue
end

#nameObject

Returns the name of this queue.



229
230
231
# File 'lib/appengine-apis/labs/taskqueue.rb', line 229

def name
  @queue.queue_name
end