Class: DisposableDB::TableTemplate
- Inherits:
-
Object
- Object
- DisposableDB::TableTemplate
- Defined in:
- lib/disposable_db/table_template.rb
Defined Under Namespace
Classes: Column
Instance Attribute Summary collapse
-
#columns ⇒ Object
Returns the value of attribute columns.
-
#name ⇒ Object
Returns the value of attribute name.
-
#primary_key ⇒ Object
Returns the value of attribute primary_key.
Instance Method Summary collapse
- #add_column(column) ⇒ Object
- #indexes ⇒ Object
-
#initialize(name, columns = []) ⇒ TableTemplate
constructor
A new instance of TableTemplate.
- #set_primary_key(pk) ⇒ Object
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
#columns ⇒ Object
Returns the value of attribute columns.
3 4 5 |
# File 'lib/disposable_db/table_template.rb', line 3 def columns @columns end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/disposable_db/table_template.rb', line 3 def name @name end |
#primary_key ⇒ Object
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 |
#indexes ⇒ Object
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 |