Class: Jack::Queues::Task
Class Attribute Summary collapse
-
.default_connection_args ⇒ Object
Returns the value of attribute default_connection_args.
Instance Attribute Summary collapse
-
#connection_args ⇒ Object
Returns the value of attribute connection_args.
-
#options ⇒ Object
Returns the value of attribute options.
-
#queue_name ⇒ Object
Returns the value of attribute queue_name.
Class Method Summary collapse
Instance Method Summary collapse
Class Attribute Details
.default_connection_args ⇒ Object
Returns the value of attribute default_connection_args.
44 45 46 |
# File 'lib/jack/queues.rb', line 44 def default_connection_args @default_connection_args end |
Instance Attribute Details
#connection_args ⇒ Object
Returns the value of attribute connection_args.
13 14 15 |
# File 'lib/jack/queues.rb', line 13 def connection_args @connection_args end |
#options ⇒ Object
Returns the value of attribute options.
14 15 16 |
# File 'lib/jack/queues.rb', line 14 def @options end |
#queue_name ⇒ Object
Returns the value of attribute queue_name.
12 13 14 |
# File 'lib/jack/queues.rb', line 12 def queue_name @queue_name end |
Class Method Details
.queue_task(name, options = {}, &block) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/jack/queues.rb', line 47 def self.queue_task(name, = {}, &block) task = define_task(name, &block) task.queue_name = .delete(:queue_name) || name task. = task.connection_args = .delete(:connect) || default_connection_args task end |
Instance Method Details
#execute ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/jack/queues.rb', line 26 def execute task = lambda do if .empty? false else super ( - kept).each do |msg| delete msg end kept.empty? end end while task.call @messages = nil end end |
#keep(*messages) ⇒ Object
20 21 22 23 24 |
# File 'lib/jack/queues.rb', line 20 def keep(*) .flatten! .uniq! kept.push * end |
#kept ⇒ Object
16 17 18 |
# File 'lib/jack/queues.rb', line 16 def kept @kept ||= [] end |