Sha256: 64969a4dae275b27a99a620e5ea33e3393a42c234d7e8cbc046533f8ebd9fa57

Contents?: true

Size: 703 Bytes

Versions: 5

Compression:

Stored size: 703 Bytes

Contents

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

5 entries across 5 versions & 1 rubygems

Version Path
rom-core-4.2.1 lib/rom/configuration_dsl/relation.rb
rom-core-4.2.0 lib/rom/configuration_dsl/relation.rb
rom-core-4.1.2 lib/rom/configuration_dsl/relation.rb
rom-core-4.1.1 lib/rom/configuration_dsl/relation.rb
rom-core-4.1.0 lib/rom/configuration_dsl/relation.rb