class EnumTable::SchemaStatements::NewTable
Public Class Methods
new(connection, name, options)
click to toggle source
# File lib/enum_table/schema_statements.rb, line 33 def initialize(connection, name, options) @connection = connection @name = name @options = options @value = DEFAULT_VALUE_ATTRIBUTES.dup @adds = [] values = options.delete(:values) and values.each { |args| add(*args) } end
Public Instance Methods
_create()
click to toggle source
# File lib/enum_table/schema_statements.rb, line 43 def _create @connection.create_table @name, @options do |t| t.column :value, @value.delete(:type), @value end unless @connection.table_exists?(:enum_tables) @connection.create_table :enum_tables, id: false, force: true do |t| t.string :table_name, null: false, limit: 255 end end @connection.execute "INSERT INTO enum_tables(table_name) VALUES(#{@connection.quote @name})" table = Table.new(@connection, @name, 0) @adds.each { |args| table.add(*args) } end
add(*args)
click to toggle source
# File lib/enum_table/schema_statements.rb, line 61 def add(*args) @adds << args end
value(options)
click to toggle source
# File lib/enum_table/schema_statements.rb, line 57 def value(options) @value.update(options) end