Sha256: 62fb62aa705fba2e8861dea9dc3108c8fab56515a6c473a1fb2133147cc9f5e9

Contents?: true

Size: 887 Bytes

Versions: 4

Compression:

Stored size: 887 Bytes

Contents

module Resque
  class SettingNotFound < RuntimeError; end

  class ThrottledJob < Job

    THROTTLE_DEFAULTS = {
        :can_run_every => 1800,
        :enqueued      => 'Your job has been submitted. You will receive an email with a download link shortly.',
        :throttled     => 'Frequency has been exceeded. Job not submitted. Try again a little later.',
        :latest        => 'Download the most recent result',
        :disabled      => false,
        :identifier    => nil
    }

    def self.settings
      @settings ||= THROTTLE_DEFAULTS.dup
    end

    def self.throttle(args = {})
      settings.merge!(args)
    end

    def self.key
      [self.to_s, identifier].compact.join(":")
    end

    def self.method_missing(method, *args)
      raise SettingNotFound("Could not find the #{method} setting") if !settings.key?(method)
      settings[method]
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
resque-throttle-0.2.3 lib/resque/throttled_job.rb
resque-throttle-0.2.2 lib/resque/throttled_job.rb
resque-throttle-0.2.1 lib/resque/throttled_job.rb
resque-throttle-0.2.0 lib/resque/throttled_job.rb