lib/sidekiq_fast_debounce/utils.rb
# Get the options for debounced Sidekiq job
# @param job [Hash] hash that represents a Sidekiq job
# @return [Hash] debounce specific options
Get the options for debounced Sidekiq job
Get the options for debounced Sidekiq job
def debounce_opts(job)
        args = job['args']
        num_args = args.length
        opts = {}
        if args.last.is_a?(Hash)
          arg_opts = args.last
          found_debounce_opt = false
          key_opts = extract_opt!(:debounce_key, arg_opts)
          if key_opts.key?(:value)
            found_debounce_opt = true
            opts[:debounce_key] = key_opts[:value]
          end
          namespace_opts = extract_opt!(:debounce_namespace, arg_opts)
          if namespace_opts.key?(:value)
            found_debounce_opt = true
            opts[:debounce_namespace] = namespace_opts[:value]
          end
          if found_debounce_opt
            if arg_opts.empty?
              args.pop
            else
              args[num_args - 1] = arg_opts
            end
          end
        end
        opts
      end
def debounce_opts ( job ) args = job [ 'args' ] num_args = args . length opts = { } if args . last . is_a? ( Hash ) arg_opts = args . last found_debounce_opt = false key_opts = extract_opt! ( :debounce_key , arg_opts ) if key_opts . key? ( :value ) found_debounce_opt = true opts [ :debounce_key ] = key_opts [ :value ] end namespace_opts = extract_opt! ( :debounce_namespace , arg_opts ) if namespace_opts . key? ( :value ) found_debounce_opt = true opts [ :debounce_namespace ] = namespace_opts [ :value ] end if found_debounce_opt if arg_opts . empty? args . pop else args [ num_args - 1 ] = arg_opts end end end opts end
Get the options for debounced Sidekiq job
Get the options for debounced Sidekiq job
debounce specific options
debounce specific options
Hash
job
hash that represents a Sidekiq job
hash that represents a Sidekiq job