Sha256: 3e0910d5ccd401e1b77aa4e7bc27245984fd5d94e7bc58710c855914d96d90bc

Contents?: true

Size: 630 Bytes

Versions: 2

Compression:

Stored size: 630 Bytes

Contents

require 'rom/sql/schema/inferrer'
require 'rom/sql/schema/associations_dsl'

module ROM
  module SQL
    class Schema < ROM::Schema
      class DSL < ROM::Schema::DSL
        attr_reader :associations_dsl

        def associations(&block)
          @associations_dsl = AssociationsDSL.new(name, &block)
        end

        def call
          SQL::Schema.new(name, attributes, opts)
        end

        def opts
          opts = { inferrer: inferrer }

          if associations_dsl
            { **opts, associations: associations_dsl.call }
          else
            opts
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rom-sql-0.9.1 lib/rom/sql/schema/dsl.rb
rom-sql-0.9.0 lib/rom/sql/schema/dsl.rb