Module: Woodhouse::Worker

Defined in:
lib/woodhouse/worker.rb

Overview

Classes which include this module become automatically visible to MixinRegistry (the default way of finding jobs in Woodhouse). All public methods of the class are automatically made available as jobs.

Classes including Woodhouse::Worker also get access to the logger method, which will be the same logger globally configured for the current Layout.

Classes including Woodhouse::Worker also have convenience shortcuts for dispatching jobs. Any job defined on the class can be dispatched asynchronously by calling ClassName.async_job_name(options).

Example

class PamPoovey
  include Woodhouse::Worker

  # This is available as the job PamPoovey#do_hr
  def do_hr(options)
    logger.info "Out comes the dolphin puppet"
  end

  private

  # This is not picked up as a job
  def fight_club
    # ...
  end
end

# later ...

Woodhouse::MixinRegistry.new[:PamPoovey] # => PamPoovey
PamPoovey.async_do_hr(:employee => "Lana")

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#loggerObject

The current Woodhouse logger. Set by the runner. Don’t expect it to be set if you create the object yourself. If you want to be able to run job methods directly, you should account for setting logger.



48
49
50
# File 'lib/woodhouse/worker.rb', line 48

def logger
  @logger
end

Class Method Details

.included(into) ⇒ Object



40
41
42
43
# File 'lib/woodhouse/worker.rb', line 40

def self.included(into)
  into.extend ClassMethods
  into.set_worker_name into.name unless into.name.nil?
end