Module: Arable::Columns::FromStructure

Defined in:
lib/arable/columns/from_structure.rb

Class Method Summary collapse

Class Method Details

.call(table_name) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/arable/columns/from_structure.rb', line 7

def call(table_name)
  return if structure.blank?

  table_definition_match = structure.match(/CREATE TABLE\s\w+\.#{table_name}.*?\n(.*?)\n *\);/m)

  table_definition_match[1]
    .lines
    .map(&:strip)
    .map { |line| line.match(/(\w*)\s/)[1] }
end