Class: Kiba::Extend::Utils::FingerprintCreator

Inherits:
Object
  • Object
show all
Defined in:
lib/kiba/extend/utils/fingerprint_creator.rb

Overview

Callable service to generate a fingerprint value from the given fields

Since:

  • 2.7.1.65

Instance Method Summary collapse

Constructor Details

#initialize(fields:, delim:) ⇒ FingerprintCreator

Returns a new instance of FingerprintCreator.

Parameters:

  • fields (Array<Symbol>)

    fields used to build the fingerprint

  • delim (String)

    to separate field values when fields are joined for hashing

Since:

  • 2.7.1.65



15
16
17
18
19
20
21
# File 'lib/kiba/extend/utils/fingerprint_creator.rb', line 15

def initialize(fields:, delim:)
  @fields = [fields].flatten
  @delim = delim
  @value_getter = Transforms::Helpers::FieldValueGetter.new(
    fields: fields, delim: delim, discard: []
  )
end

Instance Method Details

#call(row) ⇒ Object

Raises:

Since:

  • 2.7.1.65



26
27
28
29
30
31
# File 'lib/kiba/extend/utils/fingerprint_creator.rb', line 26

def call(row)
  values = value_getter.call(row).values
  check_values(values)

  Base64.strict_encode64(hashable_values(values).join(delim))
end