class DataAnon::Core::Database
Public Class Methods
Source
# File lib/core/database.rb, line 7 def initialize name @name = name @strategy = DataAnon::Strategy::Whitelist @user_defaults = {} @tables = [] @execution_strategy = DataAnon::Core::Sequential ENV['parallel_execution'] = 'false' I18n.enforce_available_locales = false end
Public Instance Methods
Source
# File lib/core/database.rb, line 44 def anonymize begin @execution_strategy.new.anonymize @tables rescue => e logger.error "\n#{e.message} \n #{e.backtrace}" end if @strategy.whitelist? @tables.each do |table| if table.fields_missing_strategy.present? logger.info('Fields missing the anonymization strategy:') table.fields_missing_strategy.print end end end @tables.each { |table| table.errors.print } end
Source
# File lib/core/database.rb, line 34 def default_field_strategies default_strategies @user_defaults = default_strategies end
Source
# File lib/core/database.rb, line 30 def destination_db connection_spec @destination_database = connection_spec end
Source
# File lib/core/database.rb, line 21 def execution_strategy execution_strategy @execution_strategy = execution_strategy ENV['parallel_execution'] = 'true' if execution_strategy == DataAnon::Parallel::Table end
Source
# File lib/core/database.rb, line 26 def source_db connection_spec @source_database = connection_spec end
Source
# File lib/core/database.rb, line 17 def strategy strategy @strategy = strategy end
Source
# File lib/core/database.rb, line 38 def table (name, &block) table = @strategy.new(@source_database, @destination_database, name, @user_defaults).process_fields(&block) @tables << table end
Also aliased as: collection