Class: ActiveRecord::ConnectionAdapters::PostgreSQLTableDefinition

Inherits:
TableDefinition
  • Object
show all
Defined in:
lib/spatial_adapter/postgresql.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#geom_columnsObject (readonly)

Returns the value of attribute geom_columns.



243
244
245
# File 'lib/spatial_adapter/postgresql.rb', line 243

def geom_columns
  @geom_columns
end

Instance Method Details

#column(name, type, options = {}) ⇒ Object



245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
# File 'lib/spatial_adapter/postgresql.rb', line 245

def column(name, type, options = {})
  unless (SpatialAdapter.geometry_data_types[type.to_sym].nil? or
          (options[:create_using_addgeometrycolumn] == false))

    column = self[name] || PostgreSQLColumnDefinition.new(@base, name, type)
    column.null = options[:null]
    column.srid = options[:srid] || -1
    column.with_z = options[:with_z] || false
    column.with_m = options[:with_m] || false
    column.geographic = options[:geographic] || false

    if column.geographic
      @columns << column unless @columns.include? column
    else
      # Hold this column for later
      @geom_columns ||= []
      @geom_columns << column
    end
    self
  else
    super(name, type, options)
  end
end