Module: Pgbus::Support

Defined in:
lib/pgbus/support.rb

Overview

Shared internal helpers.

Class Method Summary collapse

Class Method Details

.call_key_proc(key_proc, args) ⇒ Object

Call a user-supplied key proc with a job's arguments, preserving ActiveJob's keyword-argument convention: a trailing Hash whose keys are all Symbols is splatted as keywords; everything else is positional. Single implementation for Uniqueness.resolve_key and Concurrency.resolve_key so the dispatch semantics cannot drift apart.



13
14
15
16
17
18
19
20
# File 'lib/pgbus/support.rb', line 13

def call_key_proc(key_proc, args)
  last = args.last
  if last.is_a?(Hash) && last.each_key.all?(Symbol)
    key_proc.call(*args[...-1], **last)
  else
    key_proc.call(*args)
  end
end