Sha256: 33f600b8d6aa24b5f055e25e145a441d13748b952b52fcac59de6f5c6c5c6671

Contents?: true

Size: 879 Bytes

Versions: 13

Compression:

Stored size: 879 Bytes

Contents

# frozen_string_literal: true

require 'rom/sql/schema/index_dsl'

module ROM
  module SQL
    class Schema < ROM::Schema
      # Specialized schema DSL with SQL-specific features
      #
      # @api public
      class DSL < ROM::Schema::DSL
        # @!attribute [r] index_dsl
        #   @return [IndexDSL] Index DSL instance (created only if indexes block is called)
        attr_reader :index_dsl

        # Define indexes within a block
        #
        # @api public
        def indexes(&block)
          @index_dsl = IndexDSL.new(**options, &block)
        end

        private

        # Return schema options
        #
        # @api private
        def opts
          if index_dsl
            opts = super

            { **opts, indexes: index_dsl.(relation, opts[:attributes]) }
          else
            super
          end
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
rom-sql-3.6.5 lib/rom/sql/schema/dsl.rb
rom-sql-3.6.4 lib/rom/sql/schema/dsl.rb
rom-sql-3.6.3 lib/rom/sql/schema/dsl.rb
rom-sql-3.6.2 lib/rom/sql/schema/dsl.rb
rom-sql-3.6.1 lib/rom/sql/schema/dsl.rb
rom-sql-3.6.0 lib/rom/sql/schema/dsl.rb
rom-sql-3.5.0 lib/rom/sql/schema/dsl.rb
rom-sql-3.4.0 lib/rom/sql/schema/dsl.rb
rom-sql-3.3.3 lib/rom/sql/schema/dsl.rb
rom-sql-3.3.2 lib/rom/sql/schema/dsl.rb
rom-sql-3.3.1 lib/rom/sql/schema/dsl.rb
rom-sql-3.3.0 lib/rom/sql/schema/dsl.rb
rom-sql-3.2.0 lib/rom/sql/schema/dsl.rb