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



74
75
76
77
78
79
80
81
82
83
# File 'lib/vex/active_record/lite_table.rb', line 74

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



85
86
87
88
# File 'lib/vex/active_record/lite_table.rb', line 85

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