Class: DataAnon::Strategy::MongoDB::Blacklist

Inherits:
Whitelist show all
Defined in:
lib/strategy/mongodb/blacklist.rb

Instance Attribute Summary

Attributes inherited from Base

#errors, #fields, #fields_missing_strategy, #user_strategies

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Whitelist

#collection, #dest_collection, #mongo_collection, #source_collection

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

Methods included from Utils::Logging

#logger, #logger=

Constructor Details

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

Class Method Details

.whitelist?Boolean

Returns:

  • (Boolean)

6
7
8
# File 'lib/strategy/mongodb/blacklist.rb', line 6

def self.whitelist?
  false
end

Instance Method Details

#anonymize_document(document, index, field_strategies = {}) ⇒ Object


14
15
16
17
18
19
20
21
22
23
# File 'lib/strategy/mongodb/blacklist.rb', line 14

def anonymize_document document, index, field_strategies = {}
  field_strategies.each do |field_name, field_strategy|
    field_value = document[field_name]
    unless field_value.nil?
      field = DataAnon::Core::Field.new(field_name, field_value, index, document, @name)
      document[field.name] = AnonymizeField.new(field, field_strategy, self).anonymize
    end
  end
  document
end

#process_record(index, document) ⇒ Object


10
11
12
# File 'lib/strategy/mongodb/blacklist.rb', line 10

def process_record index, document
  source_collection.save anonymize_document(document, index, @fields)
end