Module: Resque::EnqueueTime

Defined in:
lib/enqueue_time.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/enqueue_time.rb', line 9

def self.included(base)
  base.class_eval do
    alias_method :push_without_enqueued_at, :push
    # Wrapper for the original Resque push method, which adds
    # enqueued_at time
    def push(queue, item)
      begin
        if item.respond_to?(:[]=)
          item[:enqueued_at] = Time.now
        end
      rescue Exception => e
        Rails.logger.error "Error in Resque::EnqueueTime: #{e.message}"
      end
      push_without_enqueued_at queue, item
    end
  end
end