Sha256: 5a424a664c61b133df2f26e215de53b235cc5de6e214c183d08f07a980864a4b

Contents?: true

Size: 711 Bytes

Versions: 8

Compression:

Stored size: 711 Bytes

Contents

require 'dry/core/class_builder'
require 'dry/core/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[#{Dry::Core::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

8 entries across 8 versions & 1 rubygems

Version Path
rom-core-4.0.2 lib/rom/configuration_dsl/relation.rb
rom-core-4.0.1 lib/rom/configuration_dsl/relation.rb
rom-core-4.0.0 lib/rom/configuration_dsl/relation.rb
rom-core-4.0.0.rc2 lib/rom/configuration_dsl/relation.rb
rom-core-4.0.0.rc1 lib/rom/configuration_dsl/relation.rb
rom-core-4.0.0.beta3 lib/rom/configuration_dsl/relation.rb
rom-core-4.0.0.beta2 lib/rom/configuration_dsl/relation.rb
rom-core-4.0.0.beta1 lib/rom/configuration_dsl/relation.rb