Class: MysqlFramework::SqlTable
- Inherits:
-
Object
- Object
- MysqlFramework::SqlTable
- Defined in:
- lib/mysql_framework/sql_table.rb
Overview
This class is used to represent a sql table
Instance Method Summary collapse
-
#[](column) ⇒ Object
This method is called to get a sql column for this table.
-
#initialize(name) ⇒ SqlTable
constructor
A new instance of SqlTable.
- #to_s ⇒ Object
- #to_sym ⇒ Object
Constructor Details
#initialize(name) ⇒ SqlTable
Returns a new instance of SqlTable.
6 7 8 9 |
# File 'lib/mysql_framework/sql_table.rb', line 6 def initialize(name) @name = name @column_objects = {} end |
Instance Method Details
#[](column) ⇒ Object
This method is called to get a sql column for this table
12 13 14 15 |
# File 'lib/mysql_framework/sql_table.rb', line 12 def [](column) return @column_objects[column.to_sym] if @column_objects[column.to_sym] @column_objects[column.to_sym] = SqlColumn.new(table: @name, column: column) end |
#to_s ⇒ Object
17 18 19 |
# File 'lib/mysql_framework/sql_table.rb', line 17 def to_s "`#{@name}`" end |
#to_sym ⇒ Object
21 22 23 |
# File 'lib/mysql_framework/sql_table.rb', line 21 def to_sym @name.to_sym end |