Sha256: 61aeba71b1164921e2dd875c83d643208810f676929a2d0d54fa078d467063d3

Contents?: true

Size: 733 Bytes

Versions: 6

Compression:

Stored size: 733 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.2.6 lib/rom/configuration_dsl/relation.rb
rom-core-5.2.5 lib/rom/configuration_dsl/relation.rb
rom-core-5.2.4 lib/rom/configuration_dsl/relation.rb
rom-core-5.2.3 lib/rom/configuration_dsl/relation.rb
rom-core-5.2.2 lib/rom/configuration_dsl/relation.rb
rom-core-5.2.1 lib/rom/configuration_dsl/relation.rb