Sha256: 992f51bcbe69649080febf02a585f76902ced5e7eadd9c82f2eccfe4848b9f27
Contents?: true
Size: 1.06 KB
Versions: 1
Compression:
Stored size: 1.06 KB
Contents
module Resque module Restriction def self.configure yield config end def self.config @config ||= Config.new end class Config def initialize @max_queue_peek = nil end def max_queue_peek=(value_or_callable) if value_or_callable.respond_to?(:call) @max_queue_peek = value_or_callable elsif value_or_callable.nil? @max_queue_peek = nil else @max_queue_peek = validated_max_queue_peek(value_or_callable) end end def max_queue_peek(queue) @max_queue_peek.respond_to?(:call) ? @max_queue_peek.call(queue) : @max_queue_peek end private def validated_max_queue_peek(value) peek = nil begin peek = Integer(value) if peek <= 0 raise ArgumentError end rescue ArgumentError raise ArgumentError, "max_queue_peek should be either nil or an Integer greater than 0 but #{value.inspect} was provided" end peek end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
resque-restriction-0.7.0 | lib/resque/restriction/config.rb |