module DbObfuscation::Filtering

Public Instance Methods

obfuscation_config(types) click to toggle source
# File lib/db_obfuscation/filtering.rb, line 11
def obfuscation_config(types)
  filter_tables.each_with_object({}) do |table, config|
    table_config = config_per_table(table, types)
    config[table] = table_config if table_config.present?
  end
end

Private Instance Methods

config_per_table(table, types) click to toggle source
# File lib/db_obfuscation/filtering.rb, line 20
def config_per_table(table, types)
  table_config = Column.columns_type(table).each_with_object({}) do |(column_name, column_type), config|
    filtered_column = Column.filter(column_name, column_type, types)
    config[column_name] = default_obfuscation_strategy(filtered_column) if filtered_column
  end.merge(user_config(table))

  reject_whitelisted_columns(table_config)
end
default_obfuscation_strategy(column) click to toggle source
# File lib/db_obfuscation/filtering.rb, line 29
def default_obfuscation_strategy(column)
  ObfuscationStrategy.strategy(column)
end
exclude_tables() click to toggle source
# File lib/db_obfuscation/filtering.rb, line 46
def exclude_tables
  DbObfuscation::Truncation.tables +
  whitelisted_tables +
  [:schema_info]
end
filter_tables() click to toggle source
# File lib/db_obfuscation/filtering.rb, line 33
def filter_tables
  DbObfuscation::DB.tables - exclude_tables
end
reject_whitelisted_columns(config) click to toggle source
# File lib/db_obfuscation/filtering.rb, line 42
def reject_whitelisted_columns(config)
  config.reject { |k,v| v == :whitelisted }
end
user_config(table) click to toggle source
# File lib/db_obfuscation/filtering.rb, line 37
def user_config(table)
  table_strategy = DbObfuscation::Config.table_strategies[table.to_s] || {}
  table_strategy.each_with_object({}) { |(k,v), config| config[k.to_sym] = v }
end
whitelisted_tables() click to toggle source
# File lib/db_obfuscation/filtering.rb, line 52
def whitelisted_tables
  DbObfuscation::Config.whitelisted_tables.map(&:to_sym)
end