Sha256: d8b99bceeee2404db81ab526e6a5b513fab80d4867b4f3747d9f96eebc998356

Contents?: true

Size: 937 Bytes

Versions: 5

Compression:

Stored size: 937 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

    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

5 entries across 5 versions & 1 rubygems

Version Path
rabbit-wq-2.1.0 lib/rabbit_wq/worker.rb
rabbit-wq-2.0.0 lib/rabbit_wq/worker.rb
rabbit-wq-1.9.0 lib/rabbit_wq/worker.rb
rabbit-wq-1.8.0 lib/rabbit_wq/worker.rb
rabbit-wq-1.7.0 lib/rabbit_wq/worker.rb