Class: MysqlFramework::SqlTable

Inherits:
Object
  • Object
show all
Defined in:
lib/mysql_framework/sql_table.rb

Overview

This class is used to represent a sql table

Instance Method Summary collapse

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_sObject



17
18
19
# File 'lib/mysql_framework/sql_table.rb', line 17

def to_s
  "`#{@name}`"
end

#to_symObject



21
22
23
# File 'lib/mysql_framework/sql_table.rb', line 21

def to_sym
  @name.to_sym
end