Class: SolidQueue::Queue
- Inherits:
-
Object
- Object
- SolidQueue::Queue
- Defined in:
- app/models/solid_queue/queue.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #==(queue) ⇒ Object (also: #eql?)
- #clear ⇒ Object
- #hash ⇒ Object
-
#initialize(name) ⇒ Queue
constructor
A new instance of Queue.
- #pause ⇒ Object
- #paused? ⇒ Boolean
- #resume ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize(name) ⇒ Queue
Returns a new instance of Queue.
19 20 21 |
# File 'app/models/solid_queue/queue.rb', line 19 def initialize(name) @name = name end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'app/models/solid_queue/queue.rb', line 5 def name @name end |
Class Method Details
.all ⇒ Object
8 9 10 11 12 |
# File 'app/models/solid_queue/queue.rb', line 8 def all Job.select(:queue_name).distinct.collect do |job| new(job.queue_name) end end |
.find_by_name(name) ⇒ Object
14 15 16 |
# File 'app/models/solid_queue/queue.rb', line 14 def find_by_name(name) new(name) end |
Instance Method Details
#==(queue) ⇒ Object Also known as: eql?
43 44 45 |
# File 'app/models/solid_queue/queue.rb', line 43 def ==(queue) name == queue.name end |
#clear ⇒ Object
35 36 37 |
# File 'app/models/solid_queue/queue.rb', line 35 def clear ReadyExecution.queued_as(name).discard_all_in_batches end |
#hash ⇒ Object
48 49 50 |
# File 'app/models/solid_queue/queue.rb', line 48 def hash name.hash end |
#pause ⇒ Object
27 28 29 |
# File 'app/models/solid_queue/queue.rb', line 27 def pause Pause.create_or_find_by!(queue_name: name) end |
#paused? ⇒ Boolean
23 24 25 |
# File 'app/models/solid_queue/queue.rb', line 23 def paused? Pause.exists?(queue_name: name) end |
#resume ⇒ Object
31 32 33 |
# File 'app/models/solid_queue/queue.rb', line 31 def resume Pause.where(queue_name: name).delete_all end |
#size ⇒ Object
39 40 41 |
# File 'app/models/solid_queue/queue.rb', line 39 def size @size ||= ReadyExecution.queued_as(name).count end |