Sha256: 1b31d43c0e119e147d7074eecbdddf3ed51085ed495f90047e12d4a3b22eb9f4
Contents?: true
Size: 1.18 KB
Versions: 11
Compression:
Stored size: 1.18 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 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
11 entries across 11 versions & 1 rubygems