Sha256: e952599ed5c169505b6c6bc0cb3d95e234c1bdca09641536e45cd4c2d47f5292

Contents?: true

Size: 1.34 KB

Versions: 11

Compression:

Stored size: 1.34 KB

Contents

# frozen_string_literal: true

module ActiveRecord
  module ConnectionAdapters
    module PostGIS
      module ColumnMethods
        def spatial(name, options = {})
          raise "You must set a type. For example: 't.spatial type: :st_point'" unless options[:type]
          column(name, options[:type], **options)
        end

        def geography(name, options = {})
          column(name, :geography, **options)
        end

        def geometry(name, options = {})
          column(name, :geometry, **options)
        end

        def geometry_collection(name, options = {})
          column(name, :geometry_collection, **options)
        end

        def line_string(name, options = {})
          column(name, :line_string, **options)
        end

        def multi_line_string(name, options = {})
          column(name, :multi_line_string, **options)
        end

        def multi_point(name, options = {})
          column(name, :multi_point, **options)
        end

        def multi_polygon(name, options = {})
          column(name, :multi_polygon, **options)
        end

        def st_point(name, options = {})
          column(name, :st_point, **options)
        end

        def st_polygon(name, options = {})
          column(name, :st_polygon, **options)
        end
      end
    end

    PostgreSQL::Table.include PostGIS::ColumnMethods
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
activerecord-postgis-adapter-8.0.3 lib/active_record/connection_adapters/postgis/column_methods.rb
activerecord-postgis-adapter-8.0.2 lib/active_record/connection_adapters/postgis/column_methods.rb
activerecord-postgis-adapter-8.0.1 lib/active_record/connection_adapters/postgis/column_methods.rb
activerecord-postgis-adapter-8.0.0 lib/active_record/connection_adapters/postgis/column_methods.rb
activerecord-postgis-adapter-7.1.1 lib/active_record/connection_adapters/postgis/column_methods.rb
activerecord-postgis-adapter-6.0.3 lib/active_record/connection_adapters/postgis/column_methods.rb
activerecord-postgis-adapter-7.1.0 lib/active_record/connection_adapters/postgis/column_methods.rb
activerecord-postgis-adapter-6.0.2 lib/active_record/connection_adapters/postgis/column_methods.rb
activerecord-postgis-adapter-7.0.1 lib/active_record/connection_adapters/postgis/column_methods.rb
activerecord-postgis-adapter-7.0.0 lib/active_record/connection_adapters/postgis/column_methods.rb
activerecord-postgis-adapter-6.0.1 lib/active_record/connection_adapters/postgis/column_methods.rb