5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/mtwtfss_yaml_db/anonymizer/dump.rb', line 5
def self.dump_table_records(io, table)
return super(io, table) unless Anonymizer.definition.is_a? Hash
return if Anonymizer.definition[table.to_s] == :truncate
(io)
column_names = table_column_names(table)
each_table_page(table) do |records|
rows = SerializationHelper::Utils.unhash_records(records, column_names)
records_anonymized = records.map do |record|
record_anonymized = []
record.each_with_index do |value, i|
if Anonymizer.anonymize(table, column_names[i], value) == 'REMOVE_ROW'
record_anonymized = 'REMOVE_ROW'
break
else
record_anonymized << Anonymizer.anonymize(table, column_names[i], value)
end
end
record_anonymized
end
records_anonymized.delete_if { |record| record == 'REMOVE_ROW' }
io.write(YamlDb::Utils.chunk_records(records_anonymized))
end
end
|