Sha256: 6b85f94d5f84ee7ccc0ca5678770fc3ce4618b4397b8dc8219ad1960fe80e178

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

require_relative "core"

module ROM
  module Components
    module DSL
      # Setup DSL-specific relation extensions
      #
      # @private
      class Relation < Core
        key :relations

        # @api private
        def call
          super(constant: constant, config: constant.config.component)
        end

        # @api private
        memoize def constant
          build_class do |dsl|
            config.component.adapter = dsl.adapter if dsl.adapter

            class_exec(&dsl.block) if dsl.block

            if (schema_dataset = components.schemas.first&.config&.dataset)
              config.component.dataset = schema_dataset
            end
          end
        end

        # @api private
        memoize def class_name
          class_name_inferrer[
            config.id,
            type: :relation,
            inflector: inflector,
            class_namespace: provider.class_namespace
          ]
        end

        # @api private
        def class_parent
          ROM::Relation[adapter]
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rom-6.0.0.alpha1 lib/rom/components/dsl/relation.rb