Module: ResqueUnitWithoutMock::ResqueHelpers::ClassMethods
- Defined in:
- lib/resque_unit_without_mock/resque_helpers.rb
Instance Method Summary collapse
- #queue_for(klass) ⇒ Object
- #queued(queue_name = :normal) ⇒ Object
- #reset! ⇒ Object
- #run!(queue_name = :normal) ⇒ Object
Instance Method Details
#queue_for(klass) ⇒ Object
23 24 25 |
# File 'lib/resque_unit_without_mock/resque_helpers.rb', line 23 def queue_for(klass) klass.instance_variable_get(:@queue) || (klass.respond_to?(:queue) && klass.queue) end |
#queued(queue_name = :normal) ⇒ Object
19 20 21 |
# File 'lib/resque_unit_without_mock/resque_helpers.rb', line 19 def queued(queue_name=:normal) Resque.redis.lrange("queue:#{queue_name}", 0, -1) end |
#reset! ⇒ Object
7 8 |
# File 'lib/resque_unit_without_mock/resque_helpers.rb', line 7 def reset! end |
#run!(queue_name = :normal) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/resque_unit_without_mock/resque_helpers.rb', line 10 def run!(queue_name=:normal) jobs = [] loop do job = Resque.reserve(queue_name) job ? (jobs << job) : break end jobs.each(&:perform) end |