Sha256: fa48d8648a80ea799614b48f78b9b9a915d447f02471f83aa2023692ae71a1f6

Contents?: true

Size: 979 Bytes

Versions: 5

Compression:

Stored size: 979 Bytes

Contents

module Resque
  module Plugins
    module RateLimited
      class UnPause
        @queue = nil

        class << self
          attr_writer(:queue)

          def use?
            Resque.respond_to?(:enqueue_at_with_queue) && @queue
          end

          def enqueue(timestamp, klass)
            # If Resque scheduler is installed and queue is set - use it to queue a wake up job
            return unless use?
            Resque.enqueue_at_with_queue(
              @queue,
              timestamp,
              Resque::Plugins::RateLimited::UnPause,
              klass
            )
          end

          def perform(klass)
            class_from_string(klass.to_s).un_pause
          end

          def class_from_string(str)
            return Object.const_get(str) unless str.include?('::')
            str.split('::').reduce(Object) do |mod, class_name|
              mod.const_get(class_name)
            end
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
resque-rate_limited-1.2.4 lib/resque/plugins/rate_limited/rate_limited_un_pause.rb
resque-rate_limited-1.2.3 lib/resque/plugins/rate_limited/rate_limited_un_pause.rb
resque-rate_limited-1.2.2 lib/resque/plugins/rate_limited/rate_limited_un_pause.rb
resque-rate_limited-1.2.0 lib/resque/plugins/rate_limited/rate_limited_un_pause.rb
resque-rate_limited-1.1.0 lib/resque/plugins/rate_limited/rate_limited_un_pause.rb