Sha256: 521fe16222ac2b068ef74cf5b1b995f064daa6c3f425af8fa1518ae3e9052a1d
Contents?: true
Size: 1.23 KB
Versions: 7
Compression:
Stored size: 1.23 KB
Contents
module Asynchronic module QueueEngine class Synchronic attr_reader :stubs def initialize(options={}) @environment = options[:environment] @stubs = {} end def default_queue Asynchronic.default_queue end def environment @environment ||= Asynchronic.environment end def [](name) Queue.new self end def stub(job, &block) @stubs[job] = block end def asynchronic? false end class Queue def initialize(engine) @engine = engine end def push(message) process = @engine.environment.load_process(message) if @engine.stubs[process.type] job = process.job block = @engine.stubs[process.type] process.define_singleton_method :job do MockJob.new job, process, &block end end process.execute end end class MockJob < TransparentProxy def initialize(job, process, &block) super job @process = process @block = block end def call @block.call @process end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems