Class: Eatr::Sql::TableGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/eatr/sql/table_generator.rb

Instance Method Summary collapse

Constructor Details

#initialize(schema_path) ⇒ TableGenerator

Returns a new instance of TableGenerator.



4
5
6
# File 'lib/eatr/sql/table_generator.rb', line 4

def initialize(schema_path)
  @schema = Schema.new(YAML.load(File.read(schema_path)))
end

Instance Method Details

#statementObject



8
9
10
11
12
13
14
# File 'lib/eatr/sql/table_generator.rb', line 8

def statement
  <<-STATEMENT
CREATE TABLE #{@schema.table_name} (
  #{column_defs.join(",\n  ")}
);
  STATEMENT
end