Sha256: 9e7e200592c6e9e44962fc0fbf095fed7f405fbf5e2fc44265d52079e4be5fb3

Contents?: true

Size: 782 Bytes

Versions: 2

Compression:

Stored size: 782 Bytes

Contents

class Woodhouse::Dispatcher

  def initialize(config, opts = {}, &blk)
    @config = config
    after_initialize(config, opts = {}, &blk)
  end

  def dispatch(class_name, job_method, arguments)
    dispatch_job Woodhouse::Job.new(class_name, job_method, arguments)
  end

  def dispatch_job(job)
    @config.dispatcher_middleware.call(job) {|job|
      deliver_job(job)
    }
    job
  end

  def update_job(job, data = {})
    deliver_job_update(job, data)
  end

  private

  def after_initialize

  end

  def deliver_job(job)
    raise NotImplementedError, "implement #deliver_job in a subclass of Woodhouse::Dispatcher"
  end

  def deliver_job_update(job, data)
    raise NotImplementedError, "implement #deliver_job_update in a subclass of Woodhouse::Dispatcher"
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
woodhouse-0.1.2 lib/woodhouse/dispatcher.rb
woodhouse-0.1.1 lib/woodhouse/dispatcher.rb