Module: Rack::DevInsight::Extractor

Defined in:
lib/rack/dev_insight/extractor.rb

Class Method Summary collapse

Class Method Details

.extract_crud_tables(dialect_name, statement) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/rack/dev_insight/extractor.rb', line 7

def extract_crud_tables(dialect_name, statement)
  crud_tables = SqlInsight.extract_crud_tables(dialect_name, statement)
  results = { 'CREATE' => [], 'READ' => [], 'UPDATE' => [], 'DELETE' => [] }

  crud_tables.each do |crud_table|
    results['CREATE'].concat(crud_table.create_tables.map(&:name).map(&:value))
    results['READ'].concat(crud_table.read_tables.map(&:name).map(&:value))
    results['UPDATE'].concat(crud_table.update_tables.map(&:name).map(&:value))
    results['DELETE'].concat(crud_table.delete_tables.map(&:name).map(&:value))
  end

  results
end