class Scheman::Schema

Public Class Methods

new(statements) click to toggle source
# File lib/scheman/schema.rb, line 3
def initialize(statements)
  @statements = statements
end

Public Instance Methods

create_tables() click to toggle source

@return [Array<Hash>] An array of CREATE TABLE statements

# File lib/scheman/schema.rb, line 12
def create_tables
  @create_tables ||= @statements.select do |statement|
    statement[:create_table]
  end
end
table_names() click to toggle source

@return [Array<String>]

# File lib/scheman/schema.rb, line 31
def table_names
  tables.map(&:name)
end
tables() click to toggle source

@return [Array<Scheman::Schema::Table>] All tables to be created after applying this schema

# File lib/scheman/schema.rb, line 24
def tables
  @tables ||= create_tables.map do |create_table|
    Table.new(create_table[:create_table])
  end
end
tables_indexed_by_name() click to toggle source

@return [Hash]

# File lib/scheman/schema.rb, line 19
def tables_indexed_by_name
  @tables_indexed_by_name ||= tables.index_by(&:name)
end
to_hash() click to toggle source
# File lib/scheman/schema.rb, line 7
def to_hash
  @statements
end