diff options
author | Eric Wong <normalperson@yhbt.net> | 2013-10-28 19:30:32 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2013-10-28 19:30:32 +0000 |
commit | 31f4772a7885a1a428eb411acd2d740c2f838c9a (patch) | |
tree | 7d8ad60145050cc95ac756148fe62b01c36678d5 /lib/yahns/config.rb | |
parent | 4602e200cff9da896339cd3bcf88c519ea96fdc5 (diff) | |
download | yahns-31f4772a7885a1a428eb411acd2d740c2f838c9a.tar.gz |
naming new (global) queues should be done outside of app contexts. Private, per-app queues should be anonymous to avoid confusion.
Diffstat (limited to 'lib/yahns/config.rb')
-rw-r--r-- | lib/yahns/config.rb | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/yahns/config.rb b/lib/yahns/config.rb index e571cb7..3d26ccb 100644 --- a/lib/yahns/config.rb +++ b/lib/yahns/config.rb @@ -227,15 +227,24 @@ class Yahns::Config # :nodoc: /:/ =~ addr ? "[#{addr}]:#{port}" : "#{addr}:#{port}" end - def queue(name = nil, &block) + def queue(*args, &block) var = :queue prev_block = @block if prev_block _check_in_block(:app, var) - name ||= @block + if block_given? + args.size == 0 or + raise ArgumentError, + "queues defined with a block inside app must not have names" + name = @block + else + name = args[0] or raise "queue must be given a name if no block given" + end else - name ||= :default + name = args[0] || :default end + args.size > 1 and + raise ArgumentError, "queue only takes one name argument" qegg = @qeggs[name] if block_given? @block = CfgBlock.new(:queue, qegg) |