Class: MasterDataTool::Dump::Executor

Inherits:
Object
  • Object
show all
Defined in:
lib/master_data_tool/dump/executor.rb

Defined Under Namespace

Classes: Error

Instance Method Summary collapse

Constructor Details

#initialize(spec_config:, dump_config:, verbose: false) ⇒ Executor

Returns a new instance of Executor.



8
9
10
11
12
# File 'lib/master_data_tool/dump/executor.rb', line 8

def initialize(spec_config:, dump_config:, verbose: false)
  @spec_config = spec_config
  @dump_config = dump_config
  @verbose = verbose
end

Instance Method Details

#executeObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/master_data_tool/dump/executor.rb', line 14

def execute
  [].tap do |errors|
    spec_config.application_record_class.connection.tables.each do |table|
      if dump_config.ignore_tables.include?(table)
        print_message "[ignore] #{table}"

        next
      end

      if dump_config.only_tables.any? && !dump_config.only_tables.include?(table)
        print_message "[skip] #{table}"
        next
      end

      dump_to_csv(table)
    rescue StandardError => e
      errors << Error.new(table, e)
    end
  end
end