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.



247
248
249
# File 'lib/spatial_adapter/postgresql.rb', line 247

def geom_columns
  @geom_columns
end

Instance Method Details

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



249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
# File 'lib/spatial_adapter/postgresql.rb', line 249

def column(name, type, options = {})
  unless (@base.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