Module: EnumTable::SchemaStatements
- Defined in:
- lib/enum_table/schema_statements.rb
Defined Under Namespace
Constant Summary collapse
- DEFAULT_VALUE_ATTRIBUTES =
{type: :string, limit: 255, null: false}.freeze
Instance Method Summary collapse
- #change_enum_table(table_name) {|Table.new(self, table_name)| ... } ⇒ Object
- #create_enum_table(table_name, options = {}) {|table| ... } ⇒ Object
- #drop_enum_table(table_name) ⇒ Object
- #enum_tables ⇒ Object
- #enum_tables_updated ⇒ Object
Instance Method Details
#change_enum_table(table_name) {|Table.new(self, table_name)| ... } ⇒ Object
10 11 12 |
# File 'lib/enum_table/schema_statements.rb', line 10 def change_enum_table(table_name) yield Table.new(self, table_name) end |
#create_enum_table(table_name, options = {}) {|table| ... } ⇒ Object
3 4 5 6 7 8 |
# File 'lib/enum_table/schema_statements.rb', line 3 def create_enum_table(table_name, ={}) table = NewTable.new(self, table_name, ) yield table if block_given? table._create enum_tables_updated end |
#drop_enum_table(table_name) ⇒ Object
14 15 16 17 18 |
# File 'lib/enum_table/schema_statements.rb', line 14 def drop_enum_table(table_name) drop_table table_name execute "DELETE FROM enum_tables WHERE table_name = #{quote table_name}" enum_tables_updated end |
#enum_tables ⇒ Object
20 21 22 23 24 |
# File 'lib/enum_table/schema_statements.rb', line 20 def enum_tables return [] if !table_exists?('enum_tables') @enum_tables ||= execute("SELECT table_name FROM enum_tables"). map { |row| row[0] }.sort end |
#enum_tables_updated ⇒ Object
26 27 28 |
# File 'lib/enum_table/schema_statements.rb', line 26 def enum_tables_updated @enum_tables = nil end |