Class: Gitlab::AlertManagement::Fingerprint

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/alert_management/fingerprint.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.generate(data) ⇒ Object


6
7
8
# File 'lib/gitlab/alert_management/fingerprint.rb', line 6

def self.generate(data)
  new.generate(data)
end

Instance Method Details

#generate(data) ⇒ Object


10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/gitlab/alert_management/fingerprint.rb', line 10

def generate(data)
  return unless data.present?

  string = case data
           when Array then flatten_array(data)
           when Hash then flatten_hash(data)
           else
             data.to_s
           end

  Digest::SHA1.hexdigest(string)
end