Class: ActiveRecord::TemporaryTable

Inherits:
Base
  • Object
show all
Defined in:
lib/ar-extensions/temporary_table.rb

Constant Summary

Constants inherited from Base

Base::AREXT_RAILS_COLUMNS, Base::AREXT_RAILS_COLUMN_NAMES

Class Method Summary collapse

Methods inherited from Base

count_union, create_temporary_table, delete_all_with_extension, delete_duplicates, find_union, fulltext, import, import_from_table, import_with_validations, import_without_validations_or_callbacks, insert_select, quote_column_names, supports_full_text_searching?, supports_import?, supports_on_duplicate_key_update?, supports_temporary_tables?, #synchronize, synchronize

Methods included from Extensions::ForeignKeys

#foreign_keys

Class Method Details

.dropObject

Drops a temporary table from the database and removes the temporary table constant.

Example

Project.create_temporary_table
Object.const_defined?( :TempProject ) # => true
TempProject.drop
Object.const_defined?( :TempProject ) # => false


112
113
114
115
116
117
118
119
120
121
# File 'lib/ar-extensions/temporary_table.rb', line 112

def self.drop
  if @@temporary_table_hsh[ self ]
    sql = 'DROP TABLE ' + self.table_name + ';'
    connection.execute( sql )
    Object.send( :remove_const, self.name.to_sym )
    @@temporary_table_hsh.delete( self )
  else
    raise StandardError.new( "Trying to drop nonexistance temporary table: #{self.name}" )
  end
end