Class: JobQueue::TestAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/job_queue/adapters/test_adapter.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ TestAdapter

Returns a new instance of TestAdapter.



2
3
4
# File 'lib/job_queue/adapters/test_adapter.rb', line 2

def initialize(options = {})
  @queue = []
end

Instance Method Details

#put(string) ⇒ Object



6
7
8
# File 'lib/job_queue/adapters/test_adapter.rb', line 6

def put(string)
  @queue << string
end

#subscribe(error_report, &block) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/job_queue/adapters/test_adapter.rb', line 10

def subscribe(error_report, &block)
  loop do
    begin
      sleep 0.1 if @queue.empty?
      yield @queue.shift
    rescue
      error_report.call(job.body, e)
    end
  end
end