Sha256: 5ab412bbf67da32042929cdd23c291933d279eb41832cdddc51e5402dc34755f

Contents?: true

Size: 806 Bytes

Versions: 2

Compression:

Stored size: 806 Bytes

Contents

# A dispatcher which simply swallows and stores jobs without performing them. This
# is to be used in testing other applications' interactions with Woodhouse.
class Woodhouse::Dispatchers::TestDispatcher < Woodhouse::Dispatcher

  # All jobs (Woodhouse::Job) which have been dispatched since this dispatcher was last cleared.
  attr_reader :jobs
  # All job updates (used in the Progress extension) which have been dispatched since this dispatcher was last cleared.
  attr_reader :job_updates
  
  # Wipe out all stored jobs and job updates.
  def clear!
    jobs.clear
    job_updates.clear
  end

  private

  def after_initialize(*)
    @jobs = []
    @job_updates = []
  end

  def deliver_job(job)
    @jobs << job
  end

  def deliver_job_update(job, data)
    @job_updates << [job, data]
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
woodhouse-1.0.0 lib/woodhouse/dispatchers/test_dispatcher.rb
woodhouse-0.1.5 lib/woodhouse/dispatchers/test_dispatcher.rb