Class: LcpRuby::BackgroundJobs::UniqueKeyBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/lcp_ruby/background_jobs/unique_key_builder.rb

Class Method Summary collapse

Class Method Details

.build(unique_by, attrs) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/lcp_ruby/background_jobs/unique_key_builder.rb', line 6

def self.build(unique_by, attrs)
  return nil unless unique_by.is_a?(Array) && unique_by.any?

  pairs = unique_by.sort.map do |key|
    value = resolve_value(key, attrs)
    "#{key}=#{value.nil? ? 'nil' : value}"
  end

  Digest::SHA256.hexdigest(pairs.join("|"))
end