Class: IronMQ::Queues
- Inherits:
-
Object
- Object
- IronMQ::Queues
- Defined in:
- lib/iron_mq/queues.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
Instance Method Summary collapse
- #clear(options = {}) ⇒ Object
- #delete(options = {}) ⇒ Object
-
#get(options = {}) ⇒ Object
options: :name => can specify an alternative queue name.
-
#initialize(client) ⇒ Queues
constructor
A new instance of Queues.
- #list(options = {}) ⇒ Object
- #path(options = {}) ⇒ Object
-
#post(options = {}) ⇒ Object
Update a queue options: :name => if not specified, will use global queue name :subscriptions => url’s to subscribe to.
Constructor Details
#initialize(client) ⇒ Queues
Returns a new instance of Queues.
8 9 10 |
# File 'lib/iron_mq/queues.rb', line 8 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
6 7 8 |
# File 'lib/iron_mq/queues.rb', line 6 def client @client end |
Instance Method Details
#clear(options = {}) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/iron_mq/queues.rb', line 33 def clear(={}) @client.logger.debug "Clearing queue #{[:name]}" r1 = @client.post("#{path()}/clear", ) @client.logger.debug "Clear result: #{r1}" r1 end |
#delete(options = {}) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/iron_mq/queues.rb', line 40 def delete(={}) @client.logger.debug "Deleting queue #{[:name]}" r1 = @client.delete("#{path()}", ) @client.logger.debug "Delete result: #{r1}" r1 end |
#get(options = {}) ⇒ Object
options:
:name => can specify an alternative queue name
49 50 51 52 53 |
# File 'lib/iron_mq/queues.rb', line 49 def get(={}) [:name] ||= @client.queue_name res = @client.parse_response(@client.get("#{path()}")) return Queue.new(@client, res) end |
#list(options = {}) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/iron_mq/queues.rb', line 20 def list(={}) ret = [] r1 = @client.get("#{path()}", ) #p r1 res = @client.parse_response(r1) res.each do |q| #p q q = Queue.new(@client, q) ret << q end ret end |
#path(options = {}) ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/iron_mq/queues.rb', line 12 def path(={}) path = "projects/#{@client.project_id}/queues" if [:name] path << "/#{CGI::escape([: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
59 60 61 62 63 64 65 |
# File 'lib/iron_mq/queues.rb', line 59 def post(={}) [:name] ||= @client.queue_name res = @client.parse_response(@client.post(path(), )) res p res end |