Sha256: fb6c469f3585c5ecf4d8adb5786366f9185c9d66da3d5e743204e4822ba1a90c

Contents?: true

Size: 836 Bytes

Versions: 4

Compression:

Stored size: 836 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.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

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

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rabbit-wq-1.6.3 lib/rabbit_wq/worker.rb
rabbit-wq-1.6.2 lib/rabbit_wq/worker.rb
rabbit-wq-1.6.1 lib/rabbit_wq/worker.rb
rabbit-wq-1.6.0 lib/rabbit_wq/worker.rb