Class: ActiveRecord::ConnectionAdapters::PostgreSQLTable

Inherits:
Table
  • Object
show all
Defined in:
lib/active_record/postgresql_extensions/tables.rb,
lib/active_record/postgresql_extensions/geometry.rb

Instance Method Summary collapse

Instance Method Details

#geography(column_name, opts = {}) ⇒ Object



354
355
356
357
358
359
360
361
362
# File 'lib/active_record/postgresql_extensions/geometry.rb', line 354

def geography(column_name, opts = {})
  opts = {
    :srid => ActiveRecord::PostgreSQLExtensions::PostGIS.UNKNOWN_SRIDS[:geography]
  }.merge(opts)

  self.spatial(column_name, opts.merge(
    :spatial_column_type => :geography
  ))
end

#post_processingObject

Add statements to execute to after a table has been created.



405
406
407
# File 'lib/active_record/postgresql_extensions/tables.rb', line 405

def post_processing
  @post_processing ||= []
end

#spatial(column_name, opts = {}) ⇒ Object Also known as: geometry



340
341
342
343
344
345
346
347
348
349
350
351
# File 'lib/active_record/postgresql_extensions/geometry.rb', line 340

def spatial(column_name, opts = {})
  column = PostgreSQLGeometryColumnDefinition.new(@base, column_name, opts)

  post_processing.concat(column.geometry_columns_entry(@table_name))
  post_processing.concat(column.geometry_column_index(@table_name))

  @base.add_column(@table_name, column_name, column.sql_type, opts)

  column.table_constraints.each do |constraint|
    @base.add_constraint(@table_name, constraint)
  end
end