Sha256: 6cbcb49b00ce87fe31d423c651ab15ad0cac4b5c7810128a47fda09840a0c179

Contents?: true

Size: 734 Bytes

Versions: 6

Compression:

Stored size: 734 Bytes

Contents

# frozen_string_literal: true

require 'dry/core/class_builder'
require 'rom/support/inflector'

module ROM
  module ConfigurationDSL
    # Setup DSL-specific relation extensions
    #
    # @private
    class Relation
      # Generate a relation subclass
      #
      # This is used by Setup#relation DSL
      #
      # @api private
      def self.build_class(name, options = EMPTY_HASH)
        class_name = "ROM::Relation[#{Inflector.camelize(name)}]"
        adapter = options.fetch(:adapter)

        Dry::Core::ClassBuilder.new(name: class_name, parent: ROM::Relation[adapter]).call do |klass|
          klass.gateway(options.fetch(:gateway, :default))
          klass.schema(name) { }
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rom-core-5.1.2 lib/rom/configuration_dsl/relation.rb
rom-core-5.1.1 lib/rom/configuration_dsl/relation.rb
rom-core-5.1.0 lib/rom/configuration_dsl/relation.rb
rom-core-5.0.2 lib/rom/configuration_dsl/relation.rb
rom-core-5.0.1 lib/rom/configuration_dsl/relation.rb
rom-core-5.0.0 lib/rom/configuration_dsl/relation.rb