Class: ActiveRecord::ConnectionAdapters::AlterTable

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record/connection_adapters/abstract/schema_definitions.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(td) ⇒ AlterTable

Returns a new instance of AlterTable.



372
373
374
375
376
377
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 372

def initialize(td)
  @td   = td
  @adds = []
  @foreign_key_adds = []
  @foreign_key_drops = []
end

Instance Attribute Details

#addsObject (readonly)

Returns the value of attribute adds.



368
369
370
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 368

def adds
  @adds
end

#foreign_key_addsObject (readonly)

Returns the value of attribute foreign_key_adds.



369
370
371
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 369

def foreign_key_adds
  @foreign_key_adds
end

#foreign_key_dropsObject (readonly)

Returns the value of attribute foreign_key_drops.



370
371
372
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 370

def foreign_key_drops
  @foreign_key_drops
end

Instance Method Details

#add_column(name, type, options) ⇒ Object



389
390
391
392
393
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 389

def add_column(name, type, options)
  name = name.to_s
  type = type.to_sym
  @adds << @td.new_column_definition(name, type, options)
end

#add_foreign_key(to_table, options) ⇒ Object



381
382
383
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 381

def add_foreign_key(to_table, options)
  @foreign_key_adds << ForeignKeyDefinition.new(name, to_table, options)
end

#drop_foreign_key(name) ⇒ Object



385
386
387
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 385

def drop_foreign_key(name)
  @foreign_key_drops << name
end

#nameObject



379
# File 'lib/active_record/connection_adapters/abstract/schema_definitions.rb', line 379

def name; @td.name; end