Class: ActiveRecord::ConnectionAdapters::AbstractAdapter::SchemaCreation

Inherits:
Object
  • Object
show all
Defined in:
activerecord/lib/active_record/connection_adapters/abstract_adapter.rb

Instance Method Summary collapse

Constructor Details

#initialize(conn) ⇒ SchemaCreation

Returns a new instance of SchemaCreation.



107
108
109
110
# File 'activerecord/lib/active_record/connection_adapters/abstract_adapter.rb', line 107

def initialize(conn)
  @conn  = conn
  @cache = {}
end

Instance Method Details

#accept(o) ⇒ Object



112
113
114
115
# File 'activerecord/lib/active_record/connection_adapters/abstract_adapter.rb', line 112

def accept(o)
  m = @cache[o.class] ||= "visit_#{o.class.name.split('::').last}"
  send m, o
end

#visit_AddColumn(o) ⇒ Object



117
118
119
120
121
# File 'activerecord/lib/active_record/connection_adapters/abstract_adapter.rb', line 117

def visit_AddColumn(o)
  sql_type = type_to_sql(o.type.to_sym, o.limit, o.precision, o.scale)
  sql = "ADD #{quote_column_name(o.name)} #{sql_type}"
  add_column_options!(sql, column_options(o))
end