Module: ActiveRecord::LiteTable

Defined in:
lib/vex/active_record/lite_table.rb

Defined Under Namespace

Classes: ColumnTypeMismatch, Validator

Instance Method Summary collapse

Instance Method Details

#lite_table(opts = {}, &block) ⇒ Object



78
79
80
81
82
83
84
85
86
87
# File 'lib/vex/active_record/lite_table.rb', line 78

def lite_table(opts={}, &block)
  # if table does not exist: create it, according to specs.
  connection.tables.include?(table_name) || 
    connection.create_table(table_name, opts) {}

  # run validator: This creates missing columns and indices. It never drops
  # any data from the database, though. 
  validator = Validator.new(self, opts)
  Proc.new.bind(validator).call
end

#remove_columns(*columns) ⇒ Object



89
90
91
92
# File 'lib/vex/active_record/lite_table.rb', line 89

def remove_columns(*columns)
  connection.remove_columns table_name, *columns
  reset_column_information
end