Class: DisposableDB::TableTemplate

Inherits:
Object
  • Object
show all
Defined in:
lib/disposable_db/table_template.rb

Defined Under Namespace

Classes: Column

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, columns = []) ⇒ TableTemplate

Returns a new instance of TableTemplate.



5
6
7
8
9
# File 'lib/disposable_db/table_template.rb', line 5

def initialize(name, columns = [])
  @name = name
  @columns = columns
  @indexes = indexes
end

Instance Attribute Details

#columnsObject

Returns the value of attribute columns.



3
4
5
# File 'lib/disposable_db/table_template.rb', line 3

def columns
  @columns
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/disposable_db/table_template.rb', line 3

def name
  @name
end

#primary_keyObject

Returns the value of attribute primary_key.



3
4
5
# File 'lib/disposable_db/table_template.rb', line 3

def primary_key
  @primary_key
end

Instance Method Details

#add_column(column) ⇒ Object



11
12
13
# File 'lib/disposable_db/table_template.rb', line 11

def add_column(column)
  @columns << column
end

#indexesObject



19
20
21
# File 'lib/disposable_db/table_template.rb', line 19

def indexes
  @columns.select{ |c| c.indexed == true }.collect{ |c| c.name }
end

#set_primary_key(pk) ⇒ Object



15
16
17
# File 'lib/disposable_db/table_template.rb', line 15

def set_primary_key(pk)
  @primary_key = pk
end