26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/pace/mock.rb', line 26
def self.enable
Pace.logger.info "Enabling Pace mock"
Pace::Worker.class_eval do
if instance_methods.include?(:start_with_mock)
alias :start :start_with_mock
else
def start_with_mock(&block)
jobs = nil
EM.run do
@redis = EM::Protocols::Redis.connect(@options)
@redis.lrange(queue, 0, -1) do |jobs|
jobs.each do |job|
block.call JSON.parse(job)
end
@redis.del(queue) { EM.stop_event_loop }
end
end
end
alias :start_without_mock :start
alias :start :start_with_mock
end
end
end
|