Sha256: 932cb7a07e101ae3d9f1a86fcb658cdc831e44e8c50937ecf11aabe4e83c493f

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

module OGR
  module LayerMixins
    module OGRSQLMethods
      # @return [Boolean]
      def start_transaction
        transact { FFI::OGR::API.OGR_L_StartTransaction(@c_pointer) }
      end

      # @return [Boolean]
      def commit_transaction
        transact { FFI::OGR::API.OGR_L_CommitTransaction(@c_pointer) }
      end

      # @return [Boolean]
      def rollback_transaction
        transact { FFI::OGR::API.OGR_L_RollbackTransaction(@c_pointer) }
      end

      # The name of the underlying database column or "" if not supported.
      #
      # @return [String]
      def fid_column
        FFI::OGR::API.OGR_L_GetFIDColumn(@c_pointer)
      end

      # The name of the underlying database column being used as the geometry
      # column.  Returns "" if not supported.
      #
      # @return [String]
      def geometry_column
        FFI::OGR::API.OGR_L_GetGeometryColumn(@c_pointer)
      end

      private

      # @return [Boolean]
      def transact
        unless supports_transactions?
          raise OGR::UnsupportedOperation, 'This layer does not support transactions.'
        end

        ogr_err = yield

        ogr_err.handle_result
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ffi-gdal-1.0.0.beta8 lib/ogr/layer_mixins/ogr_sql_methods.rb