Class: TableDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/definite/model/table_definition.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.define(table_name, options = {}, &block) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/definite/model/table_definition.rb', line 11

def self.define(table_name, options={}, &block)
  puts "Found definition for table #{table_name}"

  @table = TableDefinition.new(table_name.to_s)
  @table.instance_eval(&block)

  tables[table_name.to_s] = @table
end

.definition(table_name) ⇒ Object



3
4
5
# File 'lib/definite/model/table_definition.rb', line 3

def self.definition(table_name)
  tables[table_name]
end

.tablesObject



7
8
9
# File 'lib/definite/model/table_definition.rb', line 7

def self.tables
  @@tables ||= {}
end

Instance Method Details

#allObject



20
21
22
# File 'lib/definite/model/table_definition.rb', line 20

def all
  tables.values
end

#column(column_name, datatype, options = {}) ⇒ Object



24
25
26
# File 'lib/definite/model/table_definition.rb', line 24

def column column_name, datatype, options={}
  puts "column #{column_name}"
end

#columns(column_names) ⇒ Object



28
29
30
# File 'lib/definite/model/table_definition.rb', line 28

def columns column_names
  puts "columns #{column_names}"
end