Class: SolidQueue::QueueSelector

Inherits:
Object
  • Object
show all
Defined in:
app/models/solid_queue/queue_selector.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(queue_list, relation) ⇒ QueueSelector

Returns a new instance of QueueSelector.



7
8
9
10
# File 'app/models/solid_queue/queue_selector.rb', line 7

def initialize(queue_list, relation)
  @raw_queues = Array(queue_list).map { |queue| queue.to_s.strip }.presence || [ "*" ]
  @relation = relation
end

Instance Attribute Details

#raw_queuesObject (readonly)

Returns the value of attribute raw_queues.



5
6
7
# File 'app/models/solid_queue/queue_selector.rb', line 5

def raw_queues
  @raw_queues
end

#relationObject (readonly)

Returns the value of attribute relation.



5
6
7
# File 'app/models/solid_queue/queue_selector.rb', line 5

def relation
  @relation
end

Instance Method Details

#scoped_relationsObject



12
13
14
15
16
17
18
19
# File 'app/models/solid_queue/queue_selector.rb', line 12

def scoped_relations
  case
  when all?  then [ relation.all ]
  when none? then [ relation.none ]
  else
    queue_names.map { |queue_name| relation.queued_as(queue_name) }
  end
end