Module: GdprAdmin::Helpers::FieldAnonymizerHelper

Instance Method Summary collapse

Methods included from Anonymizers::InternetAnonymizer

#anonymize_email, #anonymize_ip, #anonymize_password, #mask_ip

Methods included from Anonymizers::ContactAnonymizer

#anonymize_city, #anonymize_country, #anonymize_country_code2, #anonymize_country_code3, #anonymize_phone_number, #anonymize_state, #anonymize_street_address, #anonymize_zip

Methods included from Anonymizers::CompanyAnonymizer

#anonymize_company

Methods included from Anonymizers::NameAnonymizer

#anonymize_first_name, #anonymize_last_name, #anonymize_name

Instance Method Details

#anonymize_field(record, field) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/gdpr_admin/helpers/field_anonymizer_helper.rb', line 16

def anonymize_field(record, field)
  field_name = field[:field]
  value = record[field_name]
  return value if value.nil?

  seed = record[field[:seed] || field_name]
  anonymize_field_value(record, field.merge(seed: seed))
end

#nilifyObject



25
26
27
# File 'lib/gdpr_admin/helpers/field_anonymizer_helper.rb', line 25

def nilify
  nil
end

#nullifyObject



29
30
31
# File 'lib/gdpr_admin/helpers/field_anonymizer_helper.rb', line 29

def nullify
  nil
end

#with_seed(seed) ⇒ Object



33
34
35
36
# File 'lib/gdpr_admin/helpers/field_anonymizer_helper.rb', line 33

def with_seed(seed)
  Faker::Config.random = Random.new(seed.to_s.chars.sum(&:ord)) if defined?(Faker)
  yield
end