class SidekiqSimpleDelay::Utils

utility methods

Constants

SYSTEM_SIMPLE_CLASSES
SYSTEM_SIMPLE_COMPLEX_CLASSES
SYSTEM_SIMPLE_NUMERIC_CLASSES

Public Class Methods

extract_option(opts, arg, default = nil) click to toggle source

@private

# File lib/sidekiq_simple_delay/utils.rb, line 49
def extract_option(opts, arg, default = nil)
  [arg.to_sym, arg.to_s].each do |a|
    next unless opts.key?(a)

    return opts.delete(a)
  end

  default
end
random_number(duration) click to toggle source
# File lib/sidekiq_simple_delay/utils.rb, line 60
def random_number(duration)
  SecureRandom.random_number(duration)
end
simple_object?(obj) click to toggle source

@private

# File lib/sidekiq_simple_delay/utils.rb, line 34
def simple_object?(obj)
  klass = obj.class

  if SYSTEM_SIMPLE_COMPLEX_CLASSES.include?(klass)
    obj.all? { |o| simple_object?(o) }
  elsif SYSTEM_SIMPLE_CLASSES.include?(klass)
    true
  elsif SYSTEM_SIMPLE_NUMERIC_CLASSES.include?(klass)
    true
  else
    false
  end
end