Class: Witsec::Alias
- Inherits:
-
Object
- Object
- Witsec::Alias
- Defined in:
- lib/witsec/alias.rb
Instance Method Summary collapse
- #anonymize(rows) ⇒ Object
-
#initialize(table_name, columns:, schema:) ⇒ Alias
constructor
A new instance of Alias.
Constructor Details
#initialize(table_name, columns:, schema:) ⇒ Alias
3 4 5 6 7 |
# File 'lib/witsec/alias.rb', line 3 def initialize(table_name, columns:, schema:) @table_name = table_name @columns = columns @schema = schema end |
Instance Method Details
#anonymize(rows) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/witsec/alias.rb', line 9 def anonymize(rows) rows.map do |row| table = schema.anonymized_tables.find { _1.name == table_name } columns.each_with_index.map do |column, index| anonymized_column, mask = table.columns.find { |name, _mask| name == column } if anonymized_column.present? mask.respond_to?(:call) ? mask.call : mask else row[index] end end end end |