Sha256: 74b370c09e3670a912f8652014118dcebbe7a373a1fdcfd3075fa4c71ba1134b

Contents?: true

Size: 691 Bytes

Versions: 6

Compression:

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

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rabbit-wq-1.5.0 lib/rabbit_wq/worker.rb
rabbit-wq-1.4.0 lib/rabbit_wq/worker.rb
rabbit-wq-1.3.0 lib/rabbit_wq/worker.rb
rabbit-wq-1.2.1 lib/rabbit_wq/worker.rb
rabbit-wq-1.2.0 lib/rabbit_wq/worker.rb
rabbit-wq-1.1.0 lib/rabbit_wq/worker.rb