Class: IronMQ::Queues

Inherits:
Object
  • Object
show all
Defined in:
lib/iron_mq/queues.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Queues

Returns a new instance of Queues.



6
7
8
# File 'lib/iron_mq/queues.rb', line 6

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



4
5
6
# File 'lib/iron_mq/queues.rb', line 4

def client
  @client
end

Instance Method Details

#get(options = {}) ⇒ Object

options:

:name => can specify an alternative queue name


33
34
35
36
37
# File 'lib/iron_mq/queues.rb', line 33

def get(options={})
  options[:name] ||= @client.queue_name
  res = @client.parse_response(@client.get("#{path(options)}"))
  return Queue.new(self, res)
end

#list(options = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/iron_mq/queues.rb', line 18

def list(options={})
  ret = []
  r1 = @client.get("#{path(options)}", options)
  #p r1
  res = @client.parse_response(r1)
  res.each do |q|
    #p q
    q = Queue.new(self, q)
    ret << q
  end
  ret
end

#path(options = {}) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/iron_mq/queues.rb', line 10

def path(options={})
  path = "projects/#{@client.project_id}/queues"
  if options[:name]
    path << "/#{options[:name]}"
  end
  path
end

#post(options = {}) ⇒ Object

Update a queue options:

:name => if not specified, will use global queue name
:subscriptions => url's to subscribe to


43
44
45
46
47
48
49
# File 'lib/iron_mq/queues.rb', line 43

def post(options={})
  options[:name] ||= @client.queue_name
  res = @client.parse_response(@client.post(path(options), options))
  res
  p res

end