Class: DataAnon::Strategy::Blacklist

Inherits:
Base
  • Object
show all
Defined in:
lib/strategy/blacklist.rb

Instance Attribute Summary

Attributes inherited from Base

#errors, #fields, #fields_missing_strategy, #user_strategies

Instance Method Summary collapse

Methods inherited from Base

#anonymize, #batch_size, #default_strategy, #dest_table, #initialize, #is_primary_key?, #primary_key, #process, #process_fields, #process_table, #process_table_in_batches, #progress_bar, #progress_bar_class, #source_table, #whitelist, whitelist?

Methods included from Utils::Logging

#logger, #logger=

Constructor Details

This class inherits a constructor from DataAnon::Strategy::Base

Instance Method Details

#process_record(index, record) ⇒ Object


5
6
7
8
9
10
11
12
13
14
15
# File 'lib/strategy/blacklist.rb', line 5

def process_record index, record
  @fields.each do |field, strategy|
    database_field_name = record.attributes.select { |k,v| k.downcase == field }.keys[0]
    field_value = record.attributes[database_field_name]
    unless field_value.nil? || is_primary_key?(database_field_name)
      field = DataAnon::Core::Field.new(database_field_name, field_value, index, record, @name)
      record[database_field_name] = strategy.anonymize(field)
    end
  end
  record.save!
end