Sha256: 61bd2ae7dd844ed3ef4e60ab70fc19be063f6c8395af26e8766807faa7a77ed6

Contents?: true

Size: 943 Bytes

Versions: 2

Compression:

Stored size: 943 Bytes

Contents

module RabbitWQ
  module Worker

    def self.included( other_module )
      other_module.class_eval do
        %w(
          debug
          error
          fatal
          info
          warn
        ).each do |level|

          define_method level do |*messages|
            return unless RabbitWQ.work_logger

            messages.each do |message|
              RabbitWQ.work_logger.send level, self, message
            end
          end

        end
      end
    end

    def work( options={} )
      RabbitWQ::Work.enqueue( self, options )
      self
    end

    def with_logging
      info "BEGIN #{self.class.name}"
      yield
      info "END   #{self.class.name}"
    end

    def enabled?
      true
    end

    def final_error( msg, level=:error )
      raise RabbitWQ::FinalError.new( level ), msg
    end

    # When true, will place the worker in error queue
    #
    def error_on_disabled?
      false
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rabbit-wq-2.3.0 lib/rabbit_wq/worker.rb
rabbit-wq-2.2.0 lib/rabbit_wq/worker.rb