Class: PerfectQueue::Queue

Inherits:
Object
  • Object
show all
Includes:
Enumerable, Model
Defined in:
lib/perfectqueue/queue.rb

Instance Attribute Summary

Attributes included from Model

#client

Instance Method Summary collapse

Methods included from Model

#config

Constructor Details

#initialize(client) ⇒ Queue

Returns a new instance of Queue.



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

def initialize(client)
  super(client)
end

Instance Method Details

#[](key) ⇒ Object



27
28
29
# File 'lib/perfectqueue/queue.rb', line 27

def [](key)
  Task.new(@client, key)
end

#closeObject



53
54
55
# File 'lib/perfectqueue/queue.rb', line 53

def close
  client.close
end

#each(options = {}, &block) ⇒ Object



31
32
33
# File 'lib/perfectqueue/queue.rb', line 31

def each(options={}, &block)
  @client.list(options, &block)
end

#poll(options = {}) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/perfectqueue/queue.rb', line 37

def poll(options={})
  options = options.merge({:max_acquire=>1})
  if acquired = poll_multi(options)
    return acquired[0]
  end
  return nil
end

#poll_multi(options = {}) ⇒ Object



45
46
47
# File 'lib/perfectqueue/queue.rb', line 45

def poll_multi(options={})
  @client.acquire(options)
end

#submit(key, type, data, options = {}) ⇒ Object



49
50
51
# File 'lib/perfectqueue/queue.rb', line 49

def submit(key, type, data, options={})
  @client.submit(key, type, data, options)
end